Hacker News new | past | comments | ask | show | jobs | submit login

Because the memory fills up. You pre-allocate a million orders, and send 800k orders a day, leaving only 200k free slots. You're going to run out mid day tomorrow if you don't restart.



Ah, OK. But I would characterize this as an internal allocator that never deallocates. You might as well replace `malloc` and `free` to do the same, and just allocate within the program normally.

Just because you "preallocate" it doesn't mean that you don't implement a poor man's allocator inside the preallocated buffer.


Sure, but calling malloc at runtime is slow and maintaining an allocator isn't very useful if you can just restart the app every night. YAGNI ;)


That just sounds like a memory leak with more words. Is the memory reclaimed/reclaimable? No? Ok then it leaked. If the system were able to reclaim the memory from the order, you wouldn't need to restart it. The memory arena strategy doesnt change that.


It's still a fine strategy. One "formal" name for it I've heard is "null garbage collector". It may feel dirty, but it's pragmatic: if the program runs in cycles with well-defined starts and ends, restarting it reclaims all memory and brings the program to a well-known state.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: