What happens to malloc'ed memory after exec() changes the program image?

前端 未结 2 686
自闭症患者
自闭症患者 2020-12-15 03:28

I know that when I call one of the exec() system calls in Linux that it will replace the currently running process with a new image. So when I fork a new proces

2条回答
  •  既然无缘
    2020-12-15 03:54

    The entire heap -- allocated memory, and all of the logic malloc uses to manage it -- is part of the process image which gets replaced. It simply disappears, as far as your process is concerned. The system, of course, recovers it and recycles it.

提交回复
热议问题