How to return memory from process to the OS

前端 未结 5 625
走了就别回头了
走了就别回头了 2020-12-16 02:54

I have an issue with memory management in various operating systems.

My program is a server that does some processing that could take a few GB of memory. After that,

5条回答
  •  长情又很酷
    2020-12-16 03:50

    I think the only reliable and portable way to do this is to spawn a spawn a new process to handle your request. Upon process exit the OS will reap all the associated memory.

    Unfortunately you then have the inefficiencies related to spawning this process and inter-process communication (I note you're doing a lot of processing - I don't know if this implies that your inter-process communication has sizable data requirements). However you will get the memory behaviour you require. Note the OS shouldn't duplicate the memory consumed by the actual JVM, provided you spawn an identical JVM binary image.

提交回复
热议问题