Kernel zeroes memory?

后端 未结 6 2096
醉梦人生
醉梦人生 2020-11-28 15:03

I am using Debian squeeze and have noticed that memory is always zeroed. Is this new in linux distributions ? Some time ago, I believe I could use puts() and garbage would b

6条回答
  •  自闭症患者
    2020-11-28 15:48

    The first time you malloc a chunk memory there's a fair chance it will be zero because memory allocated by a system call (sbrk, mmap) is zeroed by the kernel. But if you free and malloc again the memory is recycled and may not contain zero.

提交回复
热议问题