Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix: leveldb iterator memory leak #26

Merged
merged 2 commits into from
Jan 14, 2020
Merged

Commits on Jan 3, 2020

  1. 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
    Alan Shaw committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    c7e98d3 View commit details
    Browse the repository at this point in the history
  2. chore: appease linter

    Alan Shaw committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    81476a8 View commit details
    Browse the repository at this point in the history