PMNOMEM(3)

πŸ“¦
version 7.2.2 Β· 2 versions
, in arch rolling, centos-stream 10, fedora 43, fedora 44, ubuntu resolute, ubuntu stonking

πŸ’– PMNOMEM(3) β€” like, the out-of-memory reporter bestie πŸ’–

okay so this one lives in the Library Functions Manual section 3, and it's giving "your malloc just fainted and someone has to tell everybody" energy 🫢


✨ NAME ✨

pmNoMem β€” report out of memory conditions πŸ’€

yeah. it's the girl who shows up when the memory allocation said "not today" and tells the whole program about it.


🌸 C SYNOPSIS 🌸

#include <pcp/pmapi.h>

void pmNoMem(const char *where, size_t size, int fatal);

cc ... -lpcp

bestie you literally just include <pcp/pmapi.h>, call pmNoMem with three little args, and link against -lpcp. that's the whole vibe. slay πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so pmNoMem is a convenience method β€” a lil helper β€” and you reach for it when malloc(3) or one of its related memory allocation services just fails on you. 😭 it's the "welp, we're out of memory" hotline.

what does it do? it emits a standard message using pmNotifyErr(3), where your where argument gets used as the message prefix πŸŽ€ β€” and it also reports the failing allocation size while it's at it. so the message is like "here's where it broke, and here's how much memory we were begging for."

now for the spicy part, the fatal decision 🌈:

  • if fatal is zero (and PM_RECOV_ERR is zero), pmNoMem just returns β€” because the allocation failure is assumed to be recoverable by the caller. like, you got this, handle it, bestie. 🫢
  • else β€” and PM_FATAL_ERR is a good value to use in this case β€” exit(2) is called with an argument of 1. πŸšͺπŸ’¨ that's the dramatic door slam. no coming back from that one.
ngl the fatal flag is literally a vibe check: recoverable era or we're exiting the building. choose wisely πŸ‘‘

πŸ‘‘ SEE ALSO πŸ‘‘

exit(2), malloc(3), PMAPI(3) and pmNotifyErr(3).

iykyk β€” those are the friends it rolls with. ✨


and that's the whole page, fr fr πŸ“ β€” brought to you by Performance Co-Pilot (that's the PCP girlies, iconic), filed under PMNOMEM(3). go forth and report your out-of-memory moments with style πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from