Hacker News with Generative AI: Memory Management

Java 24 to Reduce Object Header Size and Save Memory (infoq.com)
JEP 450 (Compact Object Headers) has been targeted for delivery in JDK 24, and has already been merged to main.
Speculations on arenas and custom strings in C++ (nullprogram.com)
My techniques with arena allocation and strings are oriented around C. I’m always looking for a better way, and lately I’ve been experimenting with building them using C++ features. What are the trade-offs? Are the benefits worth the costs? In this article I lay out my goals, review implementation possibilities, and discuss my findings. Following along will require familiarity with those previous two articles.
Memory64 (github.com/WebAssembly)
This page describes a proposal to support linear memory of sizes larger than 232 bits. It provides no new instructions, but instead extends the currently existing instructions to allow 64-bit indexes.
Bounded Flexible Arrays in C (kernel.org)
Large projects written in C, especially those written close to the hardware layer like Linux, have long treated the language as a high-level assembler.
Tip of the day #2: A safer arena allocator (gaultier.github.io)
The most transformative action you can do to dramatically improve your code in a programming language where you are in control of the memory is: to use arenas.
Unleashing Power: Enabling Super Pages on the RPi (mairacanal.github.io)
Unleashing the power of 3D graphics in the Raspberry Pi is a key commitment for Igalia through its collaboration with Raspberry Pi. The introduction of Super Pages for the Raspberry Pi 4 and 5 marks another step in this journey, offering some performance enhancements and more efficient memory usage. In this post, we’ll dive deep into the technical details of Super Pages, discuss the challenges we faced during implementation, and illustrate the benefits this feature brings to the Raspberry Pi ecosystem.
Using less memory to look up IP addresses in Mess With DNS (jvns.ca)
I’ve been having problems for the last 3 years or so where Mess With DNS periodically runs out of memory and gets OOM killed.
Are you sure you want to use MMAP in your database management system? (2022) (cs.cmu.edu)
Memory-mapped (MMAP) file I/O is an OS-provided feature that maps the contents of a file on secondary storage into a program’s address space.
A deep dive into Linux's new mseal syscall (trailofbits.com)
If you love exploit mitigations, you may have heard of a new system call named mseal landing into the Linux kernel’s 6.10 release, providing a protection called “memory sealing.” Beyond notes from the authors, very little information about this mitigation exists. In this blog post, we’ll explain what this syscall is, including how it’s different from prior memory protection schemes and how it works in the kernel to protect virtual memory.
Smart pointers for the kernel (lwn.net)
Rust has a plethora of smart-pointer types, including reference-counted pointers, which have special support in the compiler to make them easier to use. The Rust-for-Linux project would like to reap those same benefits for its smart pointers, which need to be written by hand to conform to the Linux kernel memory model. Xiangfei Ding presented at Kangrejos about the work to enable custom smart pointers to function the same as built-in smart pointers.
How Ruby Uses Memory (2015) (sitepoint.com)
I’ve never met a developer who complained about code getting faster or taking up less RAM. In Ruby, memory is especially important, yet few developers know the ins-and-outs of why their memory use goes up or down as their code executes. This article will start you off with a basic understanding of how Ruby objects relate to memory use, and we’ll cover a few common tricks to speed up your code while using less memory.
Working Set Size Estimation (2018) (brendangregg.com)
The Working Set Size (WSS) is how much memory an application needs to keep working.
Tracking (C++) Shared Pointer Leaks (ibob.bg)
Let’s talk about shared pointer leaks. In a piece of software which makes heavy use of shared pointers such leaks are possible. They are very hard and annoying to deal with. They are also very hard to identify in the first place.
Revisiting the DOS Memory Models (blogsystem5.substack.com)
At the beginning of the year, I wrote a bunch of articles on the various tricks DOS played to overcome the tight memory limits of x86’s real mode. There was one question that came up and remained unanswered: what were the various “models” that the compilers of the day offered?
The Case of the Missing Increment (computerenhance.com)
Computer Enhance was never meant to be a place for publishing novel investigations into software performance, but sometimes it happens by accident. We already saw this once when bonus materials for the Performance-Aware Programming course lead us to discover a previously undocumented 16-ahead mapping pattern in the Windows memory manager.
Interning in Go (medium.com)
Go 1.23 comes with a new package unique implementing interning, and a blog post about it. Interning is re-using objects of equal value instead of keeping duplicate equal objects in memory. It is intended to reduce memory usage.
Generic Freelist Allocator for Go (pkg.go.dev)
This package is not in the latest version of its module.
Nesting Allocators (2023) (yoshuawuyts.com)
I regularly point people to Tmandry's 2021 post "Contexts and Capabilities in Rust". While nobody is actively working on the design at the moment, it's more because of prioritization than anything else. It seems like it could make certain usage patterns a lot nicer in Rust, and one of those is probably working with custom allocators. I've been working a lot with slab allocators recently, and I'd love it if they were easier to work with in Rust.
What is the best pointer tagging method? (coredumped.dev)
In this post, we are going to take a deep dive into pointer tagging, where metadata is encoded into a word-sized pointer. Doing so allows us to keep a compact representation that can be passed around in machine registers. This is very common in implementing dynamic programming languages, but can really be used anywhere that additional runtime information is needed about a pointer.
What is the best pointer tagging method? (coredumped.dev)
In this post, we are going to take a deep dive into pointer tagging, where metadata is encoded into a word-sized pointer. Doing so allows us to keep a compact representation that can be passed around in machine registers. This is very common in implementing dynamic programming languages, but can really be used anywhere that additional runtime information is needed about a pointer.
Zig's Memcpy, CopyForwards and CopyBackwards (openmymind.net)
Crash the GC with Random Values in Unsafe.Pointers (philpearl.github.io)
Twenty Years of Valgrind (2022) (nnethercote.github.io)
Adding 16 kb page size to Android (googleblog.com)
Async hazard: MMAP is blocking IO (huonw.github.io)
Techniques for safe garbage collection in Rust (kyju.org)
Exploiting column chunks for faster ingestion and lower memory use (rerun.io)
Linux Memory Overcommit (2007) (blogspot.com)
Ask HN: Are any databases implementing own memory paging (swapping)? (ycombinator.com)
Memory Management in DuckDB (duckdb.org)