Skip to content

Memory allocation past what is available in the container #29

Closed
@svennam92

Description

@svennam92

I've recently started investigating a memory issue with Node.js apps running in Cloud Foundry environments (I'm using CFv210). As an example, if I push a Node.js app with a mem leak and a 512MB memory limit, the Node.js V8 engine tries to allocate more and more memory until it passes that memory limit and the application crashes. The behavior I expect to see is that it will stop trying to allocate more memory when it reaches the limit, and instead try to GC more aggressively (and then crash at a later time). Has anyone else seen this behavior?

By default, on 64 bit machines, the Node.js v8 engine has a 1GB heap limit, so I can see why the engine tries to allocate more than is really available. There should be some way to prevent the Node.js v8 engine from trying to allocate more than is available. In Java, you can use JVM opts to set heap limits, maybe something similar?

I did find one thing that might help, --max-old-space-size. But... has any one done any investigation as to how to set that space size? "--max-old-space-size" only accounts for the v8 engine's heap, not the buffers or other processes. For example, should that limit be set to 50% of the memory_limit? 75%? Maybe that's something the Node.js buildpack should set as a reasonable default?

There is a separate issue that might be related to this. When I run 'free' or 'top' as a shell command from within the container spun up for my application, I am seeing "32gb" total. When I run commands like "os.totalmem()" from within Node.js, I'm also seeing 32gb. Although this is a problem that probably cannot be avoided due to use of cgroups, I wonder if this contributes to the memory issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions