-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak #8
Comments
I have the same issue, posted it on JSONStream, but I think jsonparse it is the culprit. Here was the message from the issue ( dominictarr/JSONStream#32 ): request = require('request'),
Stream = require('stream').Stream,
Parser = require('jsonparse');
var dbName = 'test'
var p = new Parser();
p.onValue = function(value) {
console.log(value)
}
var down = new Stream()
down.writable = true
down.write = function(data) {
p.write(data)
return true
}
down.end = function() {
console.log('end')
}
var host = process.env.DB_HOST
var path = '_all_docs?include_docs=true'
var url = host + '/' + dbName + '/' + path
request(url).pipe(down) Memory leak steadily increases from 50 to 260MB's, then midway through it jumps to 500-600MB's. I feel like the json parser queues up data for something then does something else with the queued data afterwards. |
@lancecarlson Is this still an issue with jsonparse? |
Its a bit of a hack, but you can add: if (parser.value) {
parser.value = {}
} to parser.onToken, and it will then store the accrued string on that empty value instead, which should get GCd at the end of the onToken method. Not sure if that helps |
Hi, is this error still valid? Does the hack from @hayes helped? Thanks. |
I'm no longer have any code that uses this library. So I'm happy for this to issue to be closed. |
Still an issue AFAICT so keep it open.
|
I have some code that uses jsonparse (via JSONStream) to parse a file that is about 170MB. The heap keeps growing, and eventually almost continual gc grinds the process almost to a halt.
I thought at first the leak was caused by dominictarr/JSONStream, but I think that I've narrowed the leak down to jsonparse.
This code causes a leak, that I don't think should happen.
It streams a never ending array of strings to jsonparse. It's silly, but it seemed to be a simple way to simulate parsing a large file and provoke the leak.
Running with the -trace_gc flag shows that the heap grows rapidly, gc is unable to reclaim much from the heap, and the heap is quickly exhausted.
I don't see why this code shouldn't be able to run indefinitely. Until it does, I'm probably not going to be able to process large files with jsonparse (which is a shame).
The text was updated successfully, but these errors were encountered: