How quickly and efficiently the OS can free up the cached RAM?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I know about the concept of "Free RAM is wasted RAM". My question is how quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage.



We have a web app hosted in linux. We normally have 10-20% memory utilisation. But we see spikes up to about 100% when certain parts of the code is invoked.(Code has been max optimised).I want to trigger an email when this happens. Should I write a script to monitor memory utilisation including Cache or just the application memory ?



When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?










share|improve this question



















  • 2




    In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have?
    – Kusalananda
    Oct 9 '17 at 7:44











  • What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory?
    – Basile Starynkevitch
    Oct 9 '17 at 10:31















up vote
0
down vote

favorite












I know about the concept of "Free RAM is wasted RAM". My question is how quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage.



We have a web app hosted in linux. We normally have 10-20% memory utilisation. But we see spikes up to about 100% when certain parts of the code is invoked.(Code has been max optimised).I want to trigger an email when this happens. Should I write a script to monitor memory utilisation including Cache or just the application memory ?



When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?










share|improve this question



















  • 2




    In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have?
    – Kusalananda
    Oct 9 '17 at 7:44











  • What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory?
    – Basile Starynkevitch
    Oct 9 '17 at 10:31













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I know about the concept of "Free RAM is wasted RAM". My question is how quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage.



We have a web app hosted in linux. We normally have 10-20% memory utilisation. But we see spikes up to about 100% when certain parts of the code is invoked.(Code has been max optimised).I want to trigger an email when this happens. Should I write a script to monitor memory utilisation including Cache or just the application memory ?



When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?










share|improve this question















I know about the concept of "Free RAM is wasted RAM". My question is how quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage.



We have a web app hosted in linux. We normally have 10-20% memory utilisation. But we see spikes up to about 100% when certain parts of the code is invoked.(Code has been max optimised).I want to trigger an email when this happens. Should I write a script to monitor memory utilisation including Cache or just the application memory ?



When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?







linux ubuntu memory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 9 '17 at 9:20

























asked Oct 9 '17 at 7:35









Jibin

1011




1011







  • 2




    In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have?
    – Kusalananda
    Oct 9 '17 at 7:44











  • What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory?
    – Basile Starynkevitch
    Oct 9 '17 at 10:31













  • 2




    In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have?
    – Kusalananda
    Oct 9 '17 at 7:44











  • What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory?
    – Basile Starynkevitch
    Oct 9 '17 at 10:31








2




2




In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have?
– Kusalananda
Oct 9 '17 at 7:44





In comparison to a network connection, the time taken to make cached memory available to a program in negligible. What issue do you have?
– Kusalananda
Oct 9 '17 at 7:44













What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory?
– Basile Starynkevitch
Oct 9 '17 at 10:31





What is that web app? Say much more about it. In what programming language? If in a compiled language, how exactly was it compiled? Better put more efforts on improving the app, or get more resources (buy more RAM), than in just coding a script to detect the situation. Do you know what exact part needs so much memory?
– Basile Starynkevitch
Oct 9 '17 at 10:31











1 Answer
1






active

oldest

votes

















up vote
0
down vote














How quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage?




Unless you are using ZFS on Linux with which the ARC might not shrink fast enough to absorb a sudden RAM demand, the time spent by the kernel to free the caches is negligible, as already commented by Kusalananda.




Should I write a script to monitor memory utilisation including Cache or just the application memory ?




I would monitor both the application memory and the system one. When the cache is reduced to make room for application memory, performance might drop because more disk I/Os are required.




When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?




When an out of memory occurs, most buffers/cache has been freed/flushed but that doesn't mean all the memory is used by applications. A part of the memory is still used by the kernel, and possibly a ram based file system or directly by some hardware.






share|improve this answer




















  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
    – Jibin
    Oct 9 '17 at 14:00










  • That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
    – jlliagre
    Oct 9 '17 at 15:25










  • Would you please care to explain
    – Jibin
    Oct 10 '17 at 5:30










  • I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
    – jlliagre
    Oct 10 '17 at 6:16










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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f396952%2fhow-quickly-and-efficiently-the-os-can-free-up-the-cached-ram%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote














How quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage?




Unless you are using ZFS on Linux with which the ARC might not shrink fast enough to absorb a sudden RAM demand, the time spent by the kernel to free the caches is negligible, as already commented by Kusalananda.




Should I write a script to monitor memory utilisation including Cache or just the application memory ?




I would monitor both the application memory and the system one. When the cache is reduced to make room for application memory, performance might drop because more disk I/Os are required.




When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?




When an out of memory occurs, most buffers/cache has been freed/flushed but that doesn't mean all the memory is used by applications. A part of the memory is still used by the kernel, and possibly a ram based file system or directly by some hardware.






share|improve this answer




















  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
    – Jibin
    Oct 9 '17 at 14:00










  • That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
    – jlliagre
    Oct 9 '17 at 15:25










  • Would you please care to explain
    – Jibin
    Oct 10 '17 at 5:30










  • I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
    – jlliagre
    Oct 10 '17 at 6:16














up vote
0
down vote














How quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage?




Unless you are using ZFS on Linux with which the ARC might not shrink fast enough to absorb a sudden RAM demand, the time spent by the kernel to free the caches is negligible, as already commented by Kusalananda.




Should I write a script to monitor memory utilisation including Cache or just the application memory ?




I would monitor both the application memory and the system one. When the cache is reduced to make room for application memory, performance might drop because more disk I/Os are required.




When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?




When an out of memory occurs, most buffers/cache has been freed/flushed but that doesn't mean all the memory is used by applications. A part of the memory is still used by the kernel, and possibly a ram based file system or directly by some hardware.






share|improve this answer




















  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
    – Jibin
    Oct 9 '17 at 14:00










  • That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
    – jlliagre
    Oct 9 '17 at 15:25










  • Would you please care to explain
    – Jibin
    Oct 10 '17 at 5:30










  • I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
    – jlliagre
    Oct 10 '17 at 6:16












up vote
0
down vote










up vote
0
down vote










How quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage?




Unless you are using ZFS on Linux with which the ARC might not shrink fast enough to absorb a sudden RAM demand, the time spent by the kernel to free the caches is negligible, as already commented by Kusalananda.




Should I write a script to monitor memory utilisation including Cache or just the application memory ?




I would monitor both the application memory and the system one. When the cache is reduced to make room for application memory, performance might drop because more disk I/Os are required.




When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?




When an out of memory occurs, most buffers/cache has been freed/flushed but that doesn't mean all the memory is used by applications. A part of the memory is still used by the kernel, and possibly a ram based file system or directly by some hardware.






share|improve this answer













How quickly and efficiently the OS can free up the cached RAM, so that apps have enough RAM in time of a spike in usage?




Unless you are using ZFS on Linux with which the ARC might not shrink fast enough to absorb a sudden RAM demand, the time spent by the kernel to free the caches is negligible, as already commented by Kusalananda.




Should I write a script to monitor memory utilisation including Cache or just the application memory ?




I would monitor both the application memory and the system one. When the cache is reduced to make room for application memory, performance might drop because more disk I/Os are required.




When the Out of Memory error occurs in linux, does it means cache memory is zero and all the RAM has been already allocated to applications ?




When an out of memory occurs, most buffers/cache has been freed/flushed but that doesn't mean all the memory is used by applications. A part of the memory is still used by the kernel, and possibly a ram based file system or directly by some hardware.







share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 9 '17 at 13:33









jlliagre

45.1k578124




45.1k578124











  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
    – Jibin
    Oct 9 '17 at 14:00










  • That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
    – jlliagre
    Oct 9 '17 at 15:25










  • Would you please care to explain
    – Jibin
    Oct 10 '17 at 5:30










  • I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
    – jlliagre
    Oct 10 '17 at 6:16
















  • Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
    – Jibin
    Oct 9 '17 at 14:00










  • That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
    – jlliagre
    Oct 9 '17 at 15:25










  • Would you please care to explain
    – Jibin
    Oct 10 '17 at 5:30










  • I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
    – jlliagre
    Oct 10 '17 at 6:16















Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
– Jibin
Oct 9 '17 at 14:00




Will the condition (app memory + cache) > 95 % occur often or only in case of usage spikes ?
– Jibin
Oct 9 '17 at 14:00












That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
– jlliagre
Oct 9 '17 at 15:25




That entirely depends on the configuration, the overall I/O usage on your machine and the running applications behavior.
– jlliagre
Oct 9 '17 at 15:25












Would you please care to explain
– Jibin
Oct 10 '17 at 5:30




Would you please care to explain
– Jibin
Oct 10 '17 at 5:30












I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
– jlliagre
Oct 10 '17 at 6:16




I mean there is no rule, that might happen very quickly, rarely or never, depending on the installed RAM and what your applications are doing with the disk, the disk size and how much of it is accessed. The simpler way to figure it out is for you to monitor your system and see how RAM usage evolves.
– jlliagre
Oct 10 '17 at 6:16

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f396952%2fhow-quickly-and-efficiently-the-os-can-free-up-the-cached-ram%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?