balderdashy / balderdashy/sails

Sails memory leak using sails-postgresql adapter and model.find

Open
#4,313 10 comments 1 reaction 1 assignee Claimed by @mikermcneil View on GitHub
more info please
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Sails version**: 1.0
**Node version**: 8.9.0
**NPM version**: 5.5.1
**DB adapter name**: sails-postrgesql
**DB adapter version**: 1.0.0-12
**Operating system**: windows 10


Well this is a repost of an issue posted on stackoverflow. https://stackoverflow.com/questions/48698000/does-v8-node-actually-garbage-collect-during-function-calls-or-is-this-a-sail

SailsJS seems to leak when repeated calling `model.find({})`. While the code uses populate, without populate it still "leaks" - though much less and it just takes more time to crash.

Github minimal example can be found at: https://github.com/pulli23/memory-leak-sails

To reproduce application must be run with the following options:

I run with the flag: --max-old-space-size=80
Environment variable: node_env=production

Then if using a POST request to localhost:1337/start-runner the runner should start (as found in WorkerController.DoRun() ). - It connects to a postgresql database (database information redacted for obvious reasons).
At my personal setup it runs about 2500 times, each time finding roughly 2000 elements.
After that node will crash reporting heap memory erro.

Increasing the max-old-space-size also dramatically increases the amount of runs, however it still crashes after "some" time.

Using a mock method (as is commented out in the github) it will *not* crash. And the program keeps running without problem.

The combination of those: Consistent crashing at about the same runcount when calling `model.find({})` and not crashing when not using a mock that creates the same result, leads me to believe there's a memory leak in sails or the adapter.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.