How to determine the process memory limit in Linux?

I scour the Internet to find out how much memory a java process can process on a linux (red-hat) machine. (I'm not talking about the heap, but rather the whole amount of memory occupied by the java process )

I do not have permission to do anything on this computer. Therefore, I can’t just execute a program that consumes memory up to the state “Without memory”.

However, I have permission to check configuration files, etc. (for example: I tried to execute cat / proc / meminfo, but I can't figure it out, it looks like none of its results match the parameter I want to know).

I tested the java program on a separate machine with red hats, on which I have permission to run programs, and I could see that the java program grows to about 3 GB.

Is there a way to find out how much memory a process can get?

+8
linux memory process out-of-memory
source share
3 answers

ulimit is your friend. Java processes are no different. But if you can’t even run ulimit -a, it’s hard for you to answer your question.

+8
source share

It is useful to read here: Limiting the time and memory consumption of programs on Linux that lead to a timeout that allows you to bind a process (and its forks) to time or memory consumption.

+4
source share

I ran into this exact problem and found a better solution, if you use 2.6.24 or higher, use cgroup / cgroups . The example will be like this, here is the default file /etc/cgconfig.conf with the added control group at the bottom. This control group limits the physical memory to 100 MB and the total virtual memory allocation to 200 MB.

mount { cpuset = /cgroup/cpuset; cpu = /cgroup/cpu; cpuacct = /cgroup/cpuacct; memory = /cgroup/memory; devices = /cgroup/devices; freezer = /cgroup/freezer; net_cls = /cgroup/net_cls; blkio = /cgroup/blkio; } group daemons/java_limited_process { memory { memory.limit_in_bytes = "104857600"; memory.memsw.limit_in_bytes = "209715200"; } } 

Once I tune in, I can add the process to the group like this

 cgexec -g memory:daemons/java_limited_process /usr/local/tomcat/bin/startup.sh 

This will limit the memory of the main process and all the children that it spawns. It also has the ability to request memory usage in controllers.

+2
source share

Source: https://habr.com/ru/post/650893/


All Articles