Thursday, August 9, 2012

Limiting memory use to a % of total memory

One of my friend was very annoyed with his application. He thinks there is one unknown process which occasionally eats up total memory available. So he was asking , if there is some way to limit memory usage to a predefined portion of total available memory. I googled , and most people say this is indeed a very very bad idea. Applications should not measure ram and occupy. If ten applications are coded, such that they occupy 1/4th of ram, and they are ran together, then crash is inevitable. In the process I learnt a way to get memory related stats on a unix system. Just parse the file at /proc/meminfo

{Used cat to see meminfo}
Otherwise  a system wide setting can also be changed using ulimit .  For more info read here. {Read the warnings at bottom first.}

No comments:

Post a Comment