Opened 5 years ago

Last modified 5 years ago

#15996 new bug

heap memory is not released to system

Reported by: X512 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/libroot.so Version: R1/Development
Keywords: Cc:
Blocked By: #13554 Blocking:
Platform: All

Description

This is hrev54155.

Test program: https://dev.haiku-os.org/attachment/ticket/15995/MemTest.cpp.

Steps to reproduce:

  1. Enable ALLOC_MALLOC and set allocSize to 64.
  2. Run program until totalSize: message will be displayed.
  3. Press enter and wait until totalSize: 0 message will be displayed.
  4. Memory is still allocated by test program that can be confirmed by ProcessController or ActivityMonitor.
  5. Press enter again that will cause program exit and freeing memory.

Change History (3)

comment:1 by pulkomandy, 5 years ago

This is expected. The team preserves its heap unless the memory is needed elsewhere (the low_resource_manager would request it to release things). Releasing pages to the system pool and then reclaiming them when a new allocation happens would waste a lot of performance.

comment:2 by X512, 5 years ago

Memory is not released when requested by another process, it just fail. You can run another intance of test program to confirm that.

Version 1, edited 5 years ago by X512 (previous) (next) (diff)

comment:3 by waddlesplash, 5 years ago

Blocked By: 13554 added

Yes, this is because the malloc we use (hoard2) is essentially sbrk-based, so it can only return memory when it can resize/cut the area in a sane way. This should be fixed when we switch to a different allocator that uses mmap() instead.

Note: See TracTickets for help on using tickets.