News for hackers. Stuff that matters.
Re:Chromium project finds that 70% of security defects are m... by _ph_ on Sunday May 24, 2020 @09:41AM (#23291440)
If your problem demands many heap allocations, GC wins also vs. manual memory management. Heap allocation in a generational GC is as fast as stack allocation, you don't get fragmented heaps.
Re:Chromium project finds that 70% of security defects are m... by pkolaczk on Sunday May 24, 2020 @02:01PM (#23293284)
It is nowhere near stack allocation, please stop this nonsense. There was a paper claiming that, but the requirement was to set heap size 7x bigger than needed.

Stack is also very hot in cache. Memory that GC is handing allocations from is not.

I recently ported some of Cassandra code from Java to stack-only Rust and I got ~25x performance improvement, most from avoiding heap allocations and GC.

Re:Chromium project finds that 70% of security defects are m... by dirtydroog on Sunday May 24, 2020 @10:26AM (#23291744)
That depends on the allocator used. The default libc one works but isn't great performance-wise. It is possible to intercept calls to malloc/free by using LD_PRELOAD on Linux. That will allow you to use allocators such as jemalloc or tcmalloc instead.

Of course, repeatedly allocating and freeing is poor for performance. Cache/pre-allocate when you can. This goes for managed languages too.