I have written a C program containing code allocating memory using the malloc()
function. If I don't free up the memory using the free()
function, will Ubuntu release it automatically?
Yes.
The kernel will release all the resources allocated by a program upon the program's termination.
This is done after the do_exit()
function defined in kernel/exit.c
has terminated its execution; the do_exit()
function execution itself might be triggered by a number of events, most commonly by an explicit exit()
syscall called by the program during its regular computation or by an implicit exit()
syscall called by the program upon its termination (as the C compiler places an exit()
syscall after main()
's return). Other reasons include the reception of an unhandable / not ignorable signal or exception.
The do_exit()
function itself performs a number of tasks. After it has terminated its execution, the program's allocated resources are released by the kernel and returned to the system for further uses.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다