How to use Node.js with Jemalloc?
up vote
2
down vote
favorite
Node.js can be used with Jemalloc (https://github.com/nodejs/node/issues/21973). In most cases it would shorten RSS and this is my huge problem.
But I can't find any info about how to use node with Jemalloc, nor on a machine, nor in docker.
Can anybody help with this?
node.js jemalloc
add a comment |
up vote
2
down vote
favorite
Node.js can be used with Jemalloc (https://github.com/nodejs/node/issues/21973). In most cases it would shorten RSS and this is my huge problem.
But I can't find any info about how to use node with Jemalloc, nor on a machine, nor in docker.
Can anybody help with this?
node.js jemalloc
I think it's done by patching node's source code or messing with the build files
– mihai
Nov 10 at 17:24
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Node.js can be used with Jemalloc (https://github.com/nodejs/node/issues/21973). In most cases it would shorten RSS and this is my huge problem.
But I can't find any info about how to use node with Jemalloc, nor on a machine, nor in docker.
Can anybody help with this?
node.js jemalloc
Node.js can be used with Jemalloc (https://github.com/nodejs/node/issues/21973). In most cases it would shorten RSS and this is my huge problem.
But I can't find any info about how to use node with Jemalloc, nor on a machine, nor in docker.
Can anybody help with this?
node.js jemalloc
node.js jemalloc
asked Nov 9 at 23:08
Terion
69811029
69811029
I think it's done by patching node's source code or messing with the build files
– mihai
Nov 10 at 17:24
add a comment |
I think it's done by patching node's source code or messing with the build files
– mihai
Nov 10 at 17:24
I think it's done by patching node's source code or messing with the build files
– mihai
Nov 10 at 17:24
I think it's done by patching node's source code or messing with the build files
– mihai
Nov 10 at 17:24
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
I just went through the process of switching our nodejs app to jemalloc, here is how I did it on Debian stretch:
Install jemalloc:
sudo apt-get install libjemalloc-dev
Find the jemalloc binary:
sudo find / -name "*jemalloc*"
Look for a file in a folder like /usr/lib/... ending with .so, for example path could be /usr/lib/x86_64-linux-gnu/libjemalloc.so
Configure server to use jemalloc for all programs:
- Create file with preloading config:
sudo nano /etc/ld.so.preload
- Add the path to the jemalloc binary to the file:
/path/to/jemalloc/binary
- Restart nodejs and check if jemalloc is used, e.g. like this (if jemalloc is used you should see some lines showing the jemalloc binary):
cat /proc/<PID OF NODEJS>/smaps | grep jemalloc
Alternative: Use jemalloc only for nodejs
In bash execute
export LD_PRELOAD=$LD_PRELOAD:/path/to/jemalloc/binary
before starting the nodejs process
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234410%2fhow-to-use-node-js-with-jemalloc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
I just went through the process of switching our nodejs app to jemalloc, here is how I did it on Debian stretch:
Install jemalloc:
sudo apt-get install libjemalloc-dev
Find the jemalloc binary:
sudo find / -name "*jemalloc*"
Look for a file in a folder like /usr/lib/... ending with .so, for example path could be /usr/lib/x86_64-linux-gnu/libjemalloc.so
Configure server to use jemalloc for all programs:
- Create file with preloading config:
sudo nano /etc/ld.so.preload
- Add the path to the jemalloc binary to the file:
/path/to/jemalloc/binary
- Restart nodejs and check if jemalloc is used, e.g. like this (if jemalloc is used you should see some lines showing the jemalloc binary):
cat /proc/<PID OF NODEJS>/smaps | grep jemalloc
Alternative: Use jemalloc only for nodejs
In bash execute
export LD_PRELOAD=$LD_PRELOAD:/path/to/jemalloc/binary
before starting the nodejs process
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
add a comment |
up vote
2
down vote
I just went through the process of switching our nodejs app to jemalloc, here is how I did it on Debian stretch:
Install jemalloc:
sudo apt-get install libjemalloc-dev
Find the jemalloc binary:
sudo find / -name "*jemalloc*"
Look for a file in a folder like /usr/lib/... ending with .so, for example path could be /usr/lib/x86_64-linux-gnu/libjemalloc.so
Configure server to use jemalloc for all programs:
- Create file with preloading config:
sudo nano /etc/ld.so.preload
- Add the path to the jemalloc binary to the file:
/path/to/jemalloc/binary
- Restart nodejs and check if jemalloc is used, e.g. like this (if jemalloc is used you should see some lines showing the jemalloc binary):
cat /proc/<PID OF NODEJS>/smaps | grep jemalloc
Alternative: Use jemalloc only for nodejs
In bash execute
export LD_PRELOAD=$LD_PRELOAD:/path/to/jemalloc/binary
before starting the nodejs process
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
add a comment |
up vote
2
down vote
up vote
2
down vote
I just went through the process of switching our nodejs app to jemalloc, here is how I did it on Debian stretch:
Install jemalloc:
sudo apt-get install libjemalloc-dev
Find the jemalloc binary:
sudo find / -name "*jemalloc*"
Look for a file in a folder like /usr/lib/... ending with .so, for example path could be /usr/lib/x86_64-linux-gnu/libjemalloc.so
Configure server to use jemalloc for all programs:
- Create file with preloading config:
sudo nano /etc/ld.so.preload
- Add the path to the jemalloc binary to the file:
/path/to/jemalloc/binary
- Restart nodejs and check if jemalloc is used, e.g. like this (if jemalloc is used you should see some lines showing the jemalloc binary):
cat /proc/<PID OF NODEJS>/smaps | grep jemalloc
Alternative: Use jemalloc only for nodejs
In bash execute
export LD_PRELOAD=$LD_PRELOAD:/path/to/jemalloc/binary
before starting the nodejs process
I just went through the process of switching our nodejs app to jemalloc, here is how I did it on Debian stretch:
Install jemalloc:
sudo apt-get install libjemalloc-dev
Find the jemalloc binary:
sudo find / -name "*jemalloc*"
Look for a file in a folder like /usr/lib/... ending with .so, for example path could be /usr/lib/x86_64-linux-gnu/libjemalloc.so
Configure server to use jemalloc for all programs:
- Create file with preloading config:
sudo nano /etc/ld.so.preload
- Add the path to the jemalloc binary to the file:
/path/to/jemalloc/binary
- Restart nodejs and check if jemalloc is used, e.g. like this (if jemalloc is used you should see some lines showing the jemalloc binary):
cat /proc/<PID OF NODEJS>/smaps | grep jemalloc
Alternative: Use jemalloc only for nodejs
In bash execute
export LD_PRELOAD=$LD_PRELOAD:/path/to/jemalloc/binary
before starting the nodejs process
edited Nov 26 at 9:55
answered Nov 21 at 13:03
Tyreal
10615
10615
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
add a comment |
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Thank you! I'll try soon. But does this mean that jemalloc will become a system-wide memory allocator?
– Terion
Nov 23 at 15:34
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
Actually yes. In case you do not want that you could do: export LD_PRELOAD=$LD_PRELOAD:<path to jemalloc binary> before starting the nodejs process. However this requires to do it each time before nodejs starts. There are probably options to only configure it for the nodejs binary but I am not aware of those right now...
– Tyreal
Nov 26 at 9:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234410%2fhow-to-use-node-js-with-jemalloc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think it's done by patching node's source code or messing with the build files
– mihai
Nov 10 at 17:24