Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

malloc() sucks

Name: Anonymous 2010-02-14 18:02

C programmers think memory management is too important to be left to the computer. Lisp programmers think memory management is too important to be left to the user.

discuss!

Name: Anonymous 2010-02-16 0:51

>>20,21
Actually this is only partially a troll. With modern operating systems it's faster to just leak all reachable memory on app exit and let the operating system reclaim your pages, instead of invoking free() on every little chunk of memory and having the allocator do a shitload of useless work.

This is standard practice on iPhone. Don't believe me? Here's the Apple documentation. See the Important block:
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/20000043-SW4

This is also why tools like Valgrind don't throw a bunch of warnings for reachable leaked memory on app exit. It's normal to just leak everything.

Of course you should not accumulate leaks; any temporary memory that doesn't need to survive the lifetime of the app should be free()d. Valgrind throws a warning if you leak something you no longer have a reference to; this is memory you should free().

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List