meebey / leveldb-sharp

C# LevelDB binding
https://www.meebey.net/projects/leveldb-sharp/
BSD 3-Clause "New" or "Revised" License
124 stars 38 forks source link

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

Closed meebey closed 11 years ago

meebey commented 11 years ago

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. ...

robashton commented 11 years ago

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.

carlosmn commented 11 years ago

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.

robashton commented 11 years ago

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/meebey/leveldb-sharp/issues/2#issuecomment-15220236 .

carlosmn commented 11 years ago

See the PR

robashton commented 11 years ago

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/meebey/leveldb-sharp/issues/2#issuecomment-15220627 .