Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

memory leak #35

Closed
soldair opened this issue Sep 14, 2015 · 0 comments
Closed

memory leak #35

soldair opened this issue Sep 14, 2015 · 0 comments

Comments

@soldair
Copy link

soldair commented Sep 14, 2015

There is a memory leak in the native binding. This simplified test leaks about 3.75mb per 100k lines , but adds up more quickly in relationship to line length.

i traced it to this line
lastSource = shared_ptr<OnigStringContext>(new OnigStringContext(v8String));
https://github.com/atom/node-oniguruma/blob/master/src/onig-scanner.cc#L74
and confirmed the leak happens with a return Nan::Null(); right after. and no leak with the return right before.

reproduction

  • run with node --expose_gc --gc_global
  • npm install prettyuse oniguruma
var pretty = require('prettyuse')
var oniguruma = require('oniguruma') 
var OnigScanner = oniguruma.OnigScanner
var oscanner = new OnigScanner([])

// excerpt from the marky-markdown readme.
var line  = "  serveImagesWithCDN: false,  // use npm's CDN to proxy images over HTTPS"

for(var i=0;i<=100000;++i){
  oscanner.findNextMatchSync(line+"\n", 0)
  if(!(i%10000)){
    gc()
    console.error('finished ',i,' usage  ',pretty())
  }
}

in heapdumps you can see the leaking strings with no GC roots which points towards a native leak as well. I'm super duper rusty working in native modules so more help would be awesome.

confirmed on node 0.10, 0.12, 2.5, and 4.0
note version ^5.0.0 only compiled for me on node 4 and i used 4.2.2 for earlier versions of node.

ceejbot added a commit to ceejbot/node-oniguruma that referenced this issue Sep 15, 2015
Added a destructor that resets the Persistent to free the memory
used for it.
ceejbot added a commit to ceejbot/node-oniguruma that referenced this issue Sep 15, 2015
Added a destructor that resets the Persistent to free the memory
used for it.
zcbenz added a commit that referenced this issue Sep 16, 2015
Fixed bug #35: memory leak in OnigStringContext
soldair pushed a commit to soldair/node-oniguruma that referenced this issue Sep 18, 2015
Added a destructor that resets the Persistent to free the memory
used for it.
@soldair soldair closed this as completed Sep 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants