On Mon, Apr 12, 2021 at 10:54:20AM -0500, Peng Yu via Libc-help wrote: > Hi, > > I don't get the point of IPC_PRIVATE of shmget(). Since it is just > used by the current process, why not just use malloc? > > Can anybody give a real example in which IPC_PRIVATE must be used, but > malloc or other variant of *alloc functions are not appropriate to > use? Thanks. Typically you get a big chunk of memory via some cousin of shmget (it is, as far as I know, rather mmap or sbrk) and you deal out small pieces of it via malloc ("big" and "small" here are somewhat flexible terms). With an allocator like malloc you don't want to incur the cost of a system call. See the mallopt(3) man page to get a rough idea on how to tune the interplay of malloc and the underlying "big chunk" [1] provider. Cheers [1] Such a big chunk is often called "arena" in allocator parlance. -- t