简体   繁体   中英

memory issue with runtime.getruntime.exec

can somebody suggest an alternative to Runtime.getRuntime().exec function of java. I am passing a unix command as an argument to this function but it causes a memory issue. Runtime.getRuntime().exec forks a new process with exactly the same amount of memory as being occupied by java process, causing the memory requirement to double which is exactly what I don't want.

This is optional and depends on the operating system. On Linux, the memory is "lazyly" allocated, until really needed. The keywords you look for are "memory overcommit", which is a situation that can arise here.

Read "How does fork handle memory" , or this to learn more. You probably have disabled the overcommit behaviour, so your forked process always allocates all memory immediately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM