This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: leveldb iterator memory leak (#26)
* fix: leveldb iterator memory leak The `.end()` method MUST be called on LevelDB iterators or they remain open, leaking memory. This PR calls `.end()` on the leveldb iterator when it is done. The added test exposes the problem by causing an error to be thrown on process exit when an iterator is open AND leveldb is not closed. Normally when leveldb is closed it'll automatically clean up open iterators but if you don't close the store this error will occur: > Assertion failed: (ended_), function ~Iterator, file ../binding.cc, line 546. This is thrown by a destructor function for iterator objects that asserts the iterator has ended before cleanup. https://github.com/Level/leveldown/blob/d3453fbde4d2a8aa04d9091101c25c999649069b/binding.cc#L545 FYI: > Destructors are usually used to deallocate memory and do other cleanup for a class object and its class members when the object is destroyed. A destructor is called for a class object when that object passes out of scope or is explicitly deleted. > https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/rzarg/cplr380.htm
- Loading branch information