Reputation: 9055
As shown above, my newly installed Node.js application directory has a lot of core.* files. What are these, and what is their purpose? Can I delete these files?
I installed Node.js behind Apache with mod_proxy that can use one of my domains on port 80. Then I installed forever. Sometimes I have problems stopping Node.js with:
forever stop server.js
Maybe that is causing those dumps? Why are these appearing?
After all the problems found their answer, my VM's processes are limited to a given number. Node.js used with Apache seems to be the background.
-bash: fork: Cannot allocate memory
Upvotes: 18
Views: 11670
Reputation: 13578
What lightness-races-in-orbit already mentioned is right:
core. files are typically memory dumps created on Linux systems. The is the Process ID of the process that crashed.
Additional to that here are some suggestions how to debug your crash:
gdb
at your servergdb /usr/bin/node /path/to/your/core.12345
With this command you are able to "read" the core-dump and look around what the cause of the crash was.
You can deactivate core-dumps if you want with:
ulimit -c 0
You also could set the max size of a core-dump (e.g. to 100MB):
ulimit -c 102400
But this don't make much sense, because as you cut the complete memory dump off, the debugger (gdb) may not be able to show full stacktrace
I found that if an node application automatically restarts (pm2, forever, etc.) the discspace could be filled up with huge core-dump files very fast. To fix this you can create a little script to just keep the very last core-dump file:
#!/bin/bash
COREDUMP_DIR="/path/to/coredumps"
MAX_CORES=5
# Count Core Dumps in folder
CORE_COUNT=$(ls -1 $COREDUMP_DIR/core.* 2>/dev/null | wc -l)
# Remove unwanted Core Dumps
if [ "$CORE_COUNT" -gt "$MAX_CORES" ]; then
ls -1t $COREDUMP_DIR/core.* | tail -n +$(($MAX_CORES + 1)) | xargs rm -f
fi
Upvotes: 0
Reputation: 280
Yea that's not normal if they are in your project file. To all the people that are downvoting his question, it's a question perfectly worth asking especially if it's in the app folder.
fefe: Can you see any sub dir within the core dir?
those look like memory dumps. So I guess you should be fine to delete them unless you want to go through them for debugging purposes.
Give this a try for debugging those crashes: https://github.com/ddopson/node-segfault-handler
Upvotes: 9
Reputation: 385088
core.<number>
files are typically memory dumps created on Linux systems. The <number>
is the Process ID of the process that crashed.
I guess your Node.JS application has crashed a number of times and these are the memory dumps left there for you to debug.
Upvotes: 22