this post was submitted on 23 Sep 2026
11 points (100.0% liked)

Programming

28663 readers
241 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS
 

Absolute gem of a channel and guy. I'm happy that since starting my programming journey 5 years ago, I could follow along with this quite well.

Still, I'm going to read into using mmap() over malloc() for full program lifetime objects. It makes sense but it doesn't feel correct.

What do you do when you want an equivalent of free()?

top 3 comments
sorted by: hot top controversial new old
[–] cheese_greater@lemmy.world 2 points 1 week ago (1 children)

Do you program professionally now or develop apps etc?

[–] tobz619@lemmy.world 2 points 1 week ago* (last edited 1 week ago)

I've had to learn 95% of everything on the job over the past 4 years. I spend most of my free time trying to make apps in Haskell.

I'm currently working on a Haskell-based renderer but right now I'm building a web-based app for synchronising multiple stakeholders and providing clear chains of responsibility as learning exercises.

[–] litchralee@sh.itjust.works 1 points 1 week ago

I didn't watch the video -- and YT isn't letting me speed-read a transcript? -- but generally speaking, if you have a need for memory that isn't backed by the filesystem, and you're writing in C, just use malloc. It's designed for that purpose, although malloc might very well be calling to mmap to obtain an anonymous mapping under the hood. Even if you're going to hold on to memory for the entire lifetime of a program, still use malloc in C.

If your application does need some filesystem backing, or if you're allocating enough memory that hugepages might be reasonable, then that's when you'd want to use mmap.