meebey/leveldb-sharp

Native.leveldb_get() leaks malloc()ed buffer returned from LevelDB

Closed this issue · 5 comments

Roman Polunin wrote:

  1. in your mapping of leveldb_get you perform Marshal.PtrToStringAnsi on the buffer returned from leveldb; however, you do not call leveldb_free on that buffer. This looks like a memory leak.
    ...

Good, I was going to report this one myself, it might be worth checking around for others as the C API allocates memory for most return calls.

FTR, FreeHGlobal fails (which gave the other issue) because this cannot free memory allocated by malloc from the CRT, as Windows seems to have four or five different ways of allocating memory.

All it takes is a call to 'free', which is exported by the wrapper as
leveldb_free

I haven't find it because I fear there are others and I'd end up looking
and checking them all

On Thursday, March 21, 2013, Carlos Martín Nieto wrote:

FTR, FreeHGlobal fails (which gave the other issue) because this cannot
free memory allocated by malloc from the CRT, as Windows seems to have
four or five different ways of allocating memory.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-15220236
.

See the PR

Sorry, on my phone - all I have is my email :) :)

On Thursday, March 21, 2013, Carlos Martín Nieto wrote:

See the PR


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-15220627
.