Skip to content

Challenges and problems with memory fragmentation #2

@bugcrazy

Description

@bugcrazy

About the issues raised in this ticket about fragmentation.

This article has a test for fragmentation:

https://www.linkedin.com/blog/engineering/infrastructure/taming-memory-fragmentation-in-venice-with-jemalloc

"Allocations are done via brk() and others via mmap(). Smaller, manageable allocations are done via brk(), while larger ones are handled via an mmap() call. Knowing how this worked, I created a bit of simple C code with a pathological pattern. It would allocate objects in two waves, and then it would delete the earlier allocations while keeping around the ones that came later. This renders the address range where they would be allocated only half-utilized by the process, but still uses the memory of all allocations made thus far.

You can watch this in action with the following code and top (though the behavior may differ slightly depending on your system’s allocator):"

https://gist.github.com/ZacAttack/8c67b998c90afdb19c715dfe327112d2/raw/e18aede445520c8762c38034e5f95feab522cd05/heap-fragmentor.cpp

There is another article talking about fragmentation and a link to the reference article about RTOS fragmentation, maybe it will help:

https://www.researchgate.net/profile/Nikola-Zlatanov/publication/295010953_Dynamic_Memory_Allocation_and_Fragmentation/links/56c6577008ae03b93dda5421/Dynamic-Memory-Allocation-and-Fragmentation.pdf

https://web.archive.org/web/20120919162407/http://www.edn.com/design/systems-design/4333346/Handling-memory-fragmentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions