Determining maximum memory usage for an extremely short process Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionNeed explanation on Resident Set Size/Virtual SizeHow to get the maximum virtual set size of a unix process during its lifetime?How to know maximum memory usage of a process?Program stall under user but runs under rootprocess memory usageFedora 20 memory.limit_in_bytes not workingActual memory usage of a processProcess killed by OOM killer when plenty of memory apparently freeHow does an OS detect an access to random memory address of a compiled program?Low-level Process analysis for getting instruction size, runnable dependencies
What do you call the holes in a flute?
Autumning in love
Choo-choo! Word trains
What do you call a plan that's an alternative plan in case your initial plan fails?
When is phishing education going too far?
Simulating Exploding Dice
Can a monk deflect thrown melee weapons?
Active filter with series inductor and resistor - do these exist?
Why is there no army of Iron-Mans in the MCU?
Stop battery usage [Ubuntu 18]
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
How can I make names more distinctive without making them longer?
What is the order of Mitzvot in Rambam's Sefer Hamitzvot?
If A makes B more likely then B makes A more likely"
Blender game recording at the wrong time
When communicating altitude with a '9' in it, should it be pronounced "nine hundred" or "niner hundred"?
Passing functions in C++
Why does this iterative way of solving of equation work?
How to say 'striped' in Latin
What can I do if my MacBook isn’t charging but already ran out?
Using "nakedly" instead of "with nothing on"
3 doors, three guards, one stone
New Order #5: where Fibonacci and Beatty meet at Wythoff
How to say that you spent the night with someone, you were only sleeping and nothing else?
Determining maximum memory usage for an extremely short process
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionNeed explanation on Resident Set Size/Virtual SizeHow to get the maximum virtual set size of a unix process during its lifetime?How to know maximum memory usage of a process?Program stall under user but runs under rootprocess memory usageFedora 20 memory.limit_in_bytes not workingActual memory usage of a processProcess killed by OOM killer when plenty of memory apparently freeHow does an OS detect an access to random memory address of a compiled program?Low-level Process analysis for getting instruction size, runnable dependencies
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.
Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.
process memory
add a comment |
I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.
Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.
process memory
Run it under a debugger and set a breakpoint?
– Celada
Apr 11 '15 at 20:55
add a comment |
I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.
Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.
process memory
I have a program I am testing and I need to determine the maximum memory used by the process.
I know that in general ps -aux
can give me this information, but the process runs in under 1/10 seconds so getting ps to catch it isn't a good option.
Are there any other good options for getting this kind of information?
I am running some benchmarks on a program to see if I can improve its memory usage.
process memory
process memory
edited Apr 11 '15 at 22:14
Gilles
548k13011131631
548k13011131631
asked Apr 11 '15 at 20:50
dnraikesdnraikes
73126
73126
Run it under a debugger and set a breakpoint?
– Celada
Apr 11 '15 at 20:55
add a comment |
Run it under a debugger and set a breakpoint?
– Celada
Apr 11 '15 at 20:55
Run it under a debugger and set a breakpoint?
– Celada
Apr 11 '15 at 20:55
Run it under a debugger and set a breakpoint?
– Celada
Apr 11 '15 at 20:55
add a comment |
3 Answers
3
active
oldest
votes
valgrind
will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.
Here's example output from running ls
:
==7051==
==7051== HEAP SUMMARY:
==7051== in use at exit: 351,689 bytes in 838 blocks
==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
==7051==
==7051== LEAK SUMMARY:
==7051== definitely lost: 0 bytes in 0 blocks
==7051== indirectly lost: 0 bytes in 0 blocks
==7051== possibly lost: 0 bytes in 0 blocks
==7051== still reachable: 351,689 bytes in 838 blocks
==7051== suppressed: 0 bytes in 0 blocks
==7051== Rerun with --leak-check=full to see details of leaked memory
==7051==
==7051== For counts of detected and suppressed errors, rerun with: -v
==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The specific information you're looking for is given by the "total heap usage" line.
add a comment |
Use GNU time (which has many more features that the builtin's "time" from bash) :
$ sudo apt-get install time
$ time prog >/dev/null
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
0inputs+0outputs (0major+119minor)pagefaults 0swaps
The time
escaping explicitly asks not to use the builtin, /usr/bin/time
would work too. There are many more display possibilites, use 'man time'.
add a comment |
This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.
I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.
The total heap usage
metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage
metric even though the peak memory demand of this is only 1MB.
Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:
valgrind --tool=massif ./<your program>
massif-visualizer massif.out.<num>
This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.
New contributor
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f195684%2fdetermining-maximum-memory-usage-for-an-extremely-short-process%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
valgrind
will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.
Here's example output from running ls
:
==7051==
==7051== HEAP SUMMARY:
==7051== in use at exit: 351,689 bytes in 838 blocks
==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
==7051==
==7051== LEAK SUMMARY:
==7051== definitely lost: 0 bytes in 0 blocks
==7051== indirectly lost: 0 bytes in 0 blocks
==7051== possibly lost: 0 bytes in 0 blocks
==7051== still reachable: 351,689 bytes in 838 blocks
==7051== suppressed: 0 bytes in 0 blocks
==7051== Rerun with --leak-check=full to see details of leaked memory
==7051==
==7051== For counts of detected and suppressed errors, rerun with: -v
==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The specific information you're looking for is given by the "total heap usage" line.
add a comment |
valgrind
will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.
Here's example output from running ls
:
==7051==
==7051== HEAP SUMMARY:
==7051== in use at exit: 351,689 bytes in 838 blocks
==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
==7051==
==7051== LEAK SUMMARY:
==7051== definitely lost: 0 bytes in 0 blocks
==7051== indirectly lost: 0 bytes in 0 blocks
==7051== possibly lost: 0 bytes in 0 blocks
==7051== still reachable: 351,689 bytes in 838 blocks
==7051== suppressed: 0 bytes in 0 blocks
==7051== Rerun with --leak-check=full to see details of leaked memory
==7051==
==7051== For counts of detected and suppressed errors, rerun with: -v
==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The specific information you're looking for is given by the "total heap usage" line.
add a comment |
valgrind
will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.
Here's example output from running ls
:
==7051==
==7051== HEAP SUMMARY:
==7051== in use at exit: 351,689 bytes in 838 blocks
==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
==7051==
==7051== LEAK SUMMARY:
==7051== definitely lost: 0 bytes in 0 blocks
==7051== indirectly lost: 0 bytes in 0 blocks
==7051== possibly lost: 0 bytes in 0 blocks
==7051== still reachable: 351,689 bytes in 838 blocks
==7051== suppressed: 0 bytes in 0 blocks
==7051== Rerun with --leak-check=full to see details of leaked memory
==7051==
==7051== For counts of detected and suppressed errors, rerun with: -v
==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The specific information you're looking for is given by the "total heap usage" line.
valgrind
will give you this information, along with a number of other statistics on memory use (and it will tell you about memory leaks etc.). It will slow the program down somewhat, but since yours is a short-lived process it shouldn't be an issue.
Here's example output from running ls
:
==7051==
==7051== HEAP SUMMARY:
==7051== in use at exit: 351,689 bytes in 838 blocks
==7051== total heap usage: 1,049 allocs, 211 frees, 688,325 bytes allocated
==7051==
==7051== LEAK SUMMARY:
==7051== definitely lost: 0 bytes in 0 blocks
==7051== indirectly lost: 0 bytes in 0 blocks
==7051== possibly lost: 0 bytes in 0 blocks
==7051== still reachable: 351,689 bytes in 838 blocks
==7051== suppressed: 0 bytes in 0 blocks
==7051== Rerun with --leak-check=full to see details of leaked memory
==7051==
==7051== For counts of detected and suppressed errors, rerun with: -v
==7051== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The specific information you're looking for is given by the "total heap usage" line.
answered Apr 11 '15 at 21:26
Stephen KittStephen Kitt
181k25415494
181k25415494
add a comment |
add a comment |
Use GNU time (which has many more features that the builtin's "time" from bash) :
$ sudo apt-get install time
$ time prog >/dev/null
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
0inputs+0outputs (0major+119minor)pagefaults 0swaps
The time
escaping explicitly asks not to use the builtin, /usr/bin/time
would work too. There are many more display possibilites, use 'man time'.
add a comment |
Use GNU time (which has many more features that the builtin's "time" from bash) :
$ sudo apt-get install time
$ time prog >/dev/null
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
0inputs+0outputs (0major+119minor)pagefaults 0swaps
The time
escaping explicitly asks not to use the builtin, /usr/bin/time
would work too. There are many more display possibilites, use 'man time'.
add a comment |
Use GNU time (which has many more features that the builtin's "time" from bash) :
$ sudo apt-get install time
$ time prog >/dev/null
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
0inputs+0outputs (0major+119minor)pagefaults 0swaps
The time
escaping explicitly asks not to use the builtin, /usr/bin/time
would work too. There are many more display possibilites, use 'man time'.
Use GNU time (which has many more features that the builtin's "time" from bash) :
$ sudo apt-get install time
$ time prog >/dev/null
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2380maxresident)k
0inputs+0outputs (0major+119minor)pagefaults 0swaps
The time
escaping explicitly asks not to use the builtin, /usr/bin/time
would work too. There are many more display possibilites, use 'man time'.
answered Apr 12 '15 at 15:13
zerodeuxzerodeux
1862
1862
add a comment |
add a comment |
This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.
I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.
The total heap usage
metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage
metric even though the peak memory demand of this is only 1MB.
Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:
valgrind --tool=massif ./<your program>
massif-visualizer massif.out.<num>
This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.
New contributor
add a comment |
This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.
I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.
The total heap usage
metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage
metric even though the peak memory demand of this is only 1MB.
Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:
valgrind --tool=massif ./<your program>
massif-visualizer massif.out.<num>
This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.
New contributor
add a comment |
This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.
I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.
The total heap usage
metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage
metric even though the peak memory demand of this is only 1MB.
Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:
valgrind --tool=massif ./<your program>
massif-visualizer massif.out.<num>
This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.
New contributor
This is an old thread, but I've just come across it when I also needed to check the memory requirements of a short running processes.
I've done some investigating and the accepted answer appears to be incorrect. The OP and myself are trying to find the maximum amount of memory that will be used at any point by the program, the peak memory demand.
The total heap usage
metric from valgrind does not measure this, it instead measures the total of all allocations during execution. So if there were 100 iterations of a loop which allocated and then freed 1MB this would contribute 100MB to the total heap usage
metric even though the peak memory demand of this is only 1MB.
Valgrind does include a tool massif which can be used to find the peak memory demand of a program, which can visualised using the massif-visualizer tool:
valgrind --tool=massif ./<your program>
massif-visualizer massif.out.<num>
This tool will plot amongst other things the total heap usage over time, and identifies the correct peak heap demand of the program. This process is described in more detail here.
New contributor
New contributor
answered 18 hours ago
PeteBlackerThe3rdPeteBlackerThe3rd
212
212
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f195684%2fdetermining-maximum-memory-usage-for-an-extremely-short-process%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
-memory, process
Run it under a debugger and set a breakpoint?
– Celada
Apr 11 '15 at 20:55