1

We use the mspace feature of Doug Lea's Malloc often referred to as dlmalloc. We have an mspace with 250 MB of objects and free all the objects. After calling mspace_trim() the size is 150 MB. We were hoping for much smaller.

When I look at mspace_trim() I do not see it freeing large and small bins. Is there a way to force freeing bins so we can get back more memory?

4
  • 1
    Don't you mean "C"? Commented Oct 8 at 16:59
  • dlmalloc is written in C. Our code that uses it is written in C++. So some of both. Commented Oct 8 at 17:25
  • Ok, it was just surprising to me. And I never heard about it. Just a quick look at the library. I see one option : create a new create_mspace, move existing objects there and destroy the old one. Or change to another allocator? I just did a quick online search and found this which might be interesting : github.com/plasma-umass/Mesh. Or do I miss something that is essential of the Doug Lea malloc that's different from normal malloc? Commented Oct 8 at 17:50
  • I was wrong about small BIN not being free'd. Objects in the BINs have boundary tags. If an object next to a BIN object is free'd, dlmalloc will consolidate the two objects into one. After freeing all objects, all the small BIN objects consolidate and the small BINs naturally empty. Commented Oct 28 at 21:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.