Rob-- / memoryjs

Read and write process memory in Node.js (Windows API functions exposed via Node bindings)
MIT License
636 stars 88 forks source link

readBytes memory leaking #69

Closed slauko closed 2 years ago

slauko commented 4 years ago

like the title says , id like to read chunks of memory but readBytes just leaking memory so i need to read 1000x for an array of DWORDs instead just once a bigger chunk and get the DWORDS from the bytes :/ pretty much unperformant that way

Rob-- commented 4 years ago

Do you mean readBuffer? Are you trying to read an array of DWORDS?

bumpmann commented 4 years ago

I also had the issue but i am not sure how to resolve this.

Here is my work but i m stuck with the Napi::Buffer::New not working well https://github.com/bumpmann/memoryjs/commit/5bbd73b099055f137c5c668d8729532205eda01c

slauko commented 4 years ago

Do you mean readBuffer? Are you trying to read an array of DWORDS?

ehh yes sorry readBuffer .. i tried reading a dword array in like 20000bytes and then convert the byte array to dwords with the buffer method readUInt32LE(offset) since this would just be 1 read instead 5k reads

but yes the readBuffer method was leaking had like 1gb ram usage after 1 sec :D

Rob-- commented 2 years ago

Fixed in b6b328a.

@bumpmann see my code comment for details about the problem with Napi::Buffer::New. Your solution was right, use Buffer::Copy and manually free the memory.

nanchengjiumeng commented 2 years ago

@Rob-- I solved the problem with your new code, but it's still the old code on NPM. Can you update the version of npm?