How to return memory from process to the OS

前端 未结 5 623
走了就别回头了
走了就别回头了 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:44

    Most of the times, memory won't be returned to the system until the process terminates. Depending on operating system and runtime library, memory might be given back to the system, but I don't know of any reliable way to make sure this will happen.

    If processing requires a few GB of memory, have your server wait for the request, then spawn a new process for processing the data - You can communicate with your server using pipes. When processing is done, return the result and terminate the spawned process.

提交回复
热议问题