Giter Club home page Giter Club logo

Comments (1)

mtrebi avatar mtrebi commented on July 20, 2024 1

Hey,

Thank you for the kind words. I did this project a while ago and I can't believe people still find it useful.

You're right about everything you said. The arena or other custom allocators work by doing fewer malloc calls (usually on startup) and then managing the memory by themselves, instead of doing a malloc every time. It is effectively one memory tool on top of another.

Why we need an additional memory tool on top of malloc? Malloc performance is not terrible but it's a bit inconsistent and sometimes it can be really slow. Malloc usually takes the memory from the user/app space if there's some available but if there's not, it needs to do system/OS call to request for more memory. This operation requires to switch the context (from user to OS and the back again to user). This is absurdly slow. The point of doing fewer mallocs, specially at start up is to reduce these slow operations, we'll do them once and that's it. After that, our allocations will be super fast.

Why the OS doesn't do that for us? Well, because it doesn't know how much memory our program will use but we do, or at least we have a rough idea. Having this information, allows us to allocate the memory in advance for our custom allocator and save syscalls.

I am no expert in this matter, so I suggest you to research about this interesting topic,

All the best,
Mariano.

from memory-allocators.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.