microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
9.74k stars 791 forks source link

Rss memory usage increase in version 2.1.4 #887

Closed adiholden closed 1 month ago

adiholden commented 2 months ago

Hi :) I am checking the last released version 2.1.4 comparing to the last one I used 2.0.9 and I see rss memory increased. Bellow is a small code reproducing the behaviour allocating 100 bytes blocks 10M times.

  auto* myheap = mi_heap_new();
  for (size_t i = 0; i < 10000000; ++i) {
    mi_heap_malloc_aligned(myheap, 100, 8);
  }
  mi_stats_print_out(NULL, NULL);

Runnig with 2.0.9 stats print is heap stats: peak total freed current unit count
reserved: 1.0 GiB 1.0 GiB 0 1.0 GiB
committed: 1.0 GiB 1.0 GiB 0 1.0 GiB
reset: 0 0 0 0 ok touched: 2.1 MiB 2.1 MiB 0 2.1 MiB not all freed! segments: 34 34 0 34 not all freed! -abandoned: 0 0 0 0 ok -cached: 0 0 0 0 ok pages: 0 0 0 0 ok -abandoned: 0 0 0 0 ok -extended: 0
-noretire: 0
mmaps: 0
commits: 0
threads: 0 0 0 0 ok searches: 0.0 avg numa nodes: 1 elapsed: 0.262 s process: user: 0.047 s, system: 0.215 s, faults: 0, rss: 1.0 GiB, commit: 1.0 GiB

while runing 2.1.4 shows

heap stats: peak total freed current unit count
reserved: 2.0 GiB 2.0 GiB 0 2.0 GiB
committed: 2.0 GiB 2.0 GiB 0 2.0 GiB
reset: 0
purged: 0
touched: 2.1 MiB 2.1 MiB 0 2.1 MiB not all freed segments: 34 34 0 34 not all freed -abandoned: 0 0 0 0 ok -cached: 0 0 0 0 ok pages: 0 0 0 0 ok -abandoned: 0 0 0 0 ok -extended: 0
-noretire: 0
arenas: 2
-crossover: 0
-rollback: 0
mmaps: 0
commits: 0
resets: 0
purges: 0
threads: 0 0 0 0 ok searches: 0.0 avg numa nodes: 1 elapsed: 0.282 s process: user: 0.076 s, system: 0.208 s, faults: 0, rss: 1.0 GiB, commit: 2.0 GiB

Why is there such a big difference in commited memory between versions? Is there any way I can change the configuration to have the same behavior as in 2.0.9 ?

romange commented 1 month ago

@daanx upon futher investigation, this issue is not real - it was caused by a dirty mimalloc build.

daanx commented 1 month ago

Ah, good to hear! Thanks for your continued support and testing!