frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Why malloc always does more than I asked for?

https://ssenthilnathan3.github.io/blog/malloc/
15•nathaah3•2d ago

Comments

irenaeus•2d ago
I've read some allocator walkthroughs before but I thought that this line stood out:

"to get individual free() working, the allocator needs to remember something about every allocation it handed out. and that’s the moment metadata stops being optional."

That's just a very nice distillation of an important concept.

nathaah3•2d ago
glad you found it useful :)
HexDecOctBin•24m ago
This becomes particularly important when the allocation and metadata cannot (or should not) be stored in the same address space. An example of this is allocating memory on GPUs.

The conventional approach for allocating memory on GPUs for games and other applications is to use a real-time allocator such as TLSF. However, it is not usually discussed that TLSF is real-time because it stores metadata in-band. It is possible to create a variant of TLSF that preserves its real-time properties while storing metadata out-of-band, but this requires careful consideration.

geocar•14m ago
Oh? How do you think munmap does it?

If you can convince the caller to keep track of that metadata themselves you obviously don’t need to. That can be important.

Something I noticed is that _very often_ the code that is calling malloc(n) is keeping track of n somehow for its own reasons (bounds checking, grow/gap pointers, etc) so merging the value halves stack churn and it’s an easy win.

lifthrasiir•11m ago
In the other words, free() is a flawed API. :-)
phire•2m ago
> so alloc() doesn’t just need to hand back a pointer. it needs to hand back a pointer that’s correctly aligned for whatever type the caller is about to store there.

Malloc doesn't know the required alignment (because has no idea what the type is, everything is cast through void). So all malloc implementations have a minimum alignment guarantee. Typically 16 bytes these days on x86, as that means even 128bit SSE values will end up aligned by default.

You couldn't go below the sizeof(void

) anyway, the backpointer needs to aligned too.

The padding only happens when you use memalign or aligned_malloc to specify a much larger alignment.

git's –end-of-options Flag

https://nesbitt.io/2026/07/21/end-of-options.html
93•Erenay09•1d ago•41 comments

Terence Tao's ChatGPT conversation about the Jacobian Conjecture counterexample

https://chatgpt.com/share/6a5fdc7a-d6f8-83e8-bbea-8deb42cfed56
785•gmays•13h ago•464 comments

Quality non-fiction books are the antithesis of AI slop

https://resobscura.substack.com/p/quality-non-fiction-books-are-the
296•benbreen•16h ago•103 comments

July 23 1985, Commodore introduced its Amiga 1000: 10 years ahead of its time

https://dfarq.homeip.net/amiga-1000-ten-years-ahead-of-its-time/
17•giuliomagnifico•1h ago•6 comments

GigaToken: ~1000x faster Language model tokenization

https://github.com/marcelroed/gigatoken/
463•syrusakbary•13h ago•96 comments

Show HN: Bento - An entire PowerPoint in one HTML file (edit+view+data+collab)

https://bento.page/slides/
765•starfallg•15h ago•170 comments

Everyone should know SIMD

https://mitchellh.com/writing/everyone-should-know-simd
367•WadeGrimridge•13h ago•117 comments

Are AI labs pelicanmaxxing?

https://dylancastillo.co/posts/pelicanmaxxing.html
480•dcastm•13h ago•184 comments

Restructuring GitHub's bug bounty program

https://github.blog/security/next-chapter-restructuring-githubs-bug-bounty-program/
38•soheilpro•4h ago•16 comments

Show HN: Cactus Hybrid: We taught Gemma 4 to know when it's wrong

https://github.com/cactus-compute/cactus-hybrid
113•HenryNdubuaku•13h ago•15 comments

ascdraw: Editor for ASCII/UTF-8 diagrams (in 144FPS)

https://github.com/exlee/ascdraw
34•xlii•2d ago•4 comments

So Reddit has decided that plain HTML is unsafe

https://www.cole-k.com/2026/07/21/reddit/
397•montroser•18h ago•390 comments

Making ASCII Art in Vim

https://alexyang.dev/vim-ascii-art/
49•evakhoury•2d ago•3 comments

Medici family mystery may be solved after more than 400 years

https://www.cnn.com/2026/07/15/science/medici-family-mystery-dna-malaria
106•effects•9h ago•27 comments

John C. Dvorak has died

https://twitter.com/na_announce/status/2079952538040672302
700•coleca•11h ago•225 comments

The startup's Postgres survival guide

https://hatchet.run/blog/postgres-survival-guide
380•abelanger•18h ago•182 comments

Malleable Computing, Emacs, and You

http://yummymelon.com/devnull/malleable-computing-emacs-and-you.html
93•kickingvegas•9h ago•27 comments

Making

https://beej.us/blog/data/ai-making/
330•erikschoster•15h ago•129 comments

Fairphone 6 wide camera experimental Linux support

https://nondescriptpointer.com/articles/fairphone-6-wide-camera-linux/
104•helonaut•10h ago•17 comments

Why malloc always does more than I asked for?

https://ssenthilnathan3.github.io/blog/malloc/
15•nathaah3•2d ago•6 comments

Nobody knows what a used GPU cluster is worth

https://ciphertalk.substack.com/p/nobody-knows-what-a-used-gpu-cluster
211•rbanffy•1w ago•191 comments

Businesses with ugly AI menu redesigns

https://blog.fiddery.com/businesses-with-ugly-ai-menu-redesigns/
245•speckx•18h ago•169 comments

All 253 Patterns from Christopher Alexander's a Pattern Language Summarized

https://claytondorge.com/patterns-list
63•toomuchtodo•9h ago•8 comments

Petals: Run LLMs at home, BitTorrent-style

https://petals.dev/
96•snorbleck•5h ago•31 comments

Clarity didn't work, trying mysterianism (2012)

https://gwern.net/doc/fiction/science-fiction/2012-10-03-yvain-thewhisperingearring.html
67•dboon•12h ago•37 comments

Back to Kagi

https://blog.melashri.net/micro/back-to-kagi/
247•speckx•17h ago•189 comments

Honey Bee Colony Monitoring via Audio IoT Sensors, Tensorgrams and RNNs

https://arxiv.org/abs/2607.20386
15•StatsAreFun•5h ago•0 comments

Codeberg Bans Cryptocurrency Projects

https://codeberg.org/Codeberg/org/pulls/1254
236•intunderflow•5h ago•322 comments

Any text-to-SQL benchmark should address difficulties of real-world data stores

https://cacm.acm.org/blogcacm/if-you-think-you-can-do-real-world-text-to-sql/
47•shenli3514•9h ago•15 comments

Ghost Cut – or why Cut and Paste is broken everywhere

https://ishmael.textualize.io/blog/ghost-cut/
153•willm•16h ago•100 comments