3 ms·
There is malloc and free. Anything you do above that to make your life easier is up to you. C is pretty darn simple in terms of memory management -- you own i
by jmspring 13y ago
There is malloc and free.
Anything you do above that to make your life easier is up to you.
C is pretty darn simple in terms of memory management -- you own it, deal with it. If that is too hard, find a higher level language.
- adamnemecek 13y agoWhat's your point exactly?
- jmspring 13y agoI welcome the down votes. My point - I read the article and agree as described are typical ways of dealing with memory in C (and in particular within Nethack). At the end of the day, dynamic memory allocation comes down to tracking mallocs and frees and whatever extra book keeping you put on top of them. Reference counting came up. There are libraries that help with such, but you better understand what that actually means. Wrapping primitives in higher level abstractions can lead many developers to wondering why there is a memory leak. Before you embrace the abstractions, you better darn well understand what is going on under the hood. I've seen many inexperienced devs get lost in simple valgrind dumps.
- ANTSANTS 13y agoYou're being downvoted because these comments have little to do with the content of the article, which is about "dirty" low-level memory management techniques designed to avoid naive heap allocation, not trying to abstract the problem away.
- eru 13y agoMalloc and free are not as low level as you portrait them. They actually do quite a bit of work, that could be done differently. The article talked about different issues, though.
- deleted 13y ago[deleted]
- dllthomas 13y agoThere is plenty of memory management in C that has nothing to do with malloc or free. More accurate (on POSIX systems), although not terribly useful, would be: There is mmap and there is munmap and there is brk. Anything you do above that (including malloc, static allocation, and the stack) to make your life easier is probably built upon things provided by libc and the C runtime. On an embedded system, all you might have is "there is RAM".