2 ms·
Why would the heap make memory usage unpredictable? How’s it any different than the stack? For example, if I stack allocate 1000 bytes, leaving the function fre
by colejohnson66 5y ago
Why would the heap make memory usage unpredictable? How’s it any different than the stack? For example, if I stack allocate 1000 bytes, leaving the function frees those bytes (by destroying the frame). If I allocate those 1000 bytes on the heap instead and make sure to free() it, there’s no change to memory usage.
- Dylan16807 5y agoIt's easier to figure out what calls what and the maximum stack depth of some or all of the program. Trying to track maximum usage based on allocations is a lot harder, especially when you have to deal with fragmentation.