Skip to content
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 #3

Closed
gothammm opened this issue Apr 12, 2016 · 7 comments
Closed

Memory Leak #3

gothammm opened this issue Apr 12, 2016 · 7 comments

Comments

@gothammm
Copy link

I started using log4js-node-mongodb, to move logs to my mongodb.

Later I started noticing, the increase in the memory consumption, whenever I switch to log4js-node-mongo appender, this is not the same when I use the console appender.

Any help is appreciated.

@4kochi
Copy link
Collaborator

4kochi commented Apr 12, 2016

We will check this.

@gothammm
Copy link
Author

For Example:

I'm trying to hit an end-point, that does nothing but log a single statement - hitting that endpoint with around 200 req/s, the memory consumption shoots up like crazy, while logging onto mongo, but not with console.

@4kochi
Copy link
Collaborator

4kochi commented Apr 12, 2016

I can reproduce it. Will check if it's a problem with the code of our module or the mongdb driver module.

@gothammm
Copy link
Author

👍 Thanks!

@4kochi
Copy link
Collaborator

4kochi commented Apr 13, 2016

I have done some tests which writes a lot of log entries in the mongo db. The memory usage grows until a certain amount an then the v8 Garbage Collector kicks in. So there is no leak i can found. But at which point the Garbage Collector starts to freeing up memory differs in each node.js version. And in general if there is enough memory in your system then the garbage collection might not even run.

You can find more informations about the garbage collection in node.js here:

nodejs/node#2738
nodejs/node#3370 (comment)

@4kochi 4kochi closed this as completed Apr 13, 2016
@gothammm
Copy link
Author

Can you tell me, to how much did it grow until the GC kicks in?

Also I wanted to know why is there so much growth in memory while writing to db? Any idea?

@4kochi
Copy link
Collaborator

4kochi commented Apr 14, 2016

On my machine with 8 GB RAM the memory growths up to 1 GB for the node app. Then it was cleaned during the following operations and at the end the memory usage dropped to ~150 MB.

In MongoDB the data is first written to the memory and later to the disk. So if you have a large amount of write operations then the memory increases fast and is freed up later when the data was saved to the disk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants