Negative current commited stat with purge_delay=0
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c
- Domain
- operating-systems, performance
Research direction
Start by running the minimal C reproducer with mi_option_purge_decommits, mi_option_purge_delay, mi_collect, and mi_stats_get, then compare the reported committed.current value with the printed mappings. Review the existing discussion in duplicate issues #929 and #1118; done means the committed statistic no longer becomes negative or its documented meaning explains the result.
Written by the indexing model from the issue text.
Description
Duplicate of #929 #1118, but I want to bump this issue up so it gains more attention. With mi_option_purge_decommits=1 and mi_option_purge_delay=0, the current commited stat becomes negative after calling mi_collect. I first assumed that this is the current amount of memory that is not yet decommited (relative to total), but it doesn't add up. So its either a bug or an undocumented feature.
Running with latest master:
#include <stdio.h>
#include <mimalloc.h>
#include <mimalloc-stats.h>
int main() {
const int num_elements = 1000;
void* ptrs[num_elements];
mi_process_init();
mi_option_set(mi_option_purge_decommits, 1);
mi_option_set(mi_option_purge_delay, 0);
mi_option_set(mi_option_arena_reserve, 1024000); // 1GB
for (int i = 0; i < num_elements; i++) {
ptrs[i] = mi_malloc(50000);
}
for (int i = 0; i < num_elements; i++) {
mi_free(ptrs[i]);
}
mi_collect(true);
mi_stats_t stats;
mi_stats_get(sizeof(stats), &stats);
printf("%d mb", stats.committed.current / 1024 / 1024);
mi_stats_print_out(NULL, NULL);
}
[100%] Built target test
heap stats: peak total current block total#
reserved: 1.0 GiB 1.0 GiB 1.0 GiB
committed: 1.0 GiB 1.0 GiB -906.8 MiB
reset: 0
purged: 1.8 GiB
touched: 192.7 KiB 192.7 KiB -54.6 MiB
segments: 3 3 1 not all freed
-abandoned: 0 0 0 ok
-cached: 0 0 0 ok
pages: 0 0 -121 not all freed
-abandoned: 0 0 0 ok
-extended: 0
-retire: 0
arenas: 1
-rollback: 0
mmaps: 1
commits: 0
resets: 0
purges: 123
guarded: 0
threads: 0 0 0 ok
searches: 0.0 avg
numa nodes: 1
elapsed: 0.009 s
process: user: 0.000 s, system: 0.009 s, faults: 0, rss: 63.5 MiB, commit: 1.0 GiB
-906 mb%
pmap -x 77734 | grep -e "total \| RSS"
Address Kbytes RSS Dirty Mode Mapping
total kB 1051248 1868 220
- Dominant language
- C
- Stars
- 13.6k
- Forks
- 1.2k
- Avg merge
- 18h 12m
- Merged PRs (30d)
- 20
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/mimalloc
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Building mimalloc with `-Wundef` compiler flag logs many warnings on undefined macrosPossibly taken @vstinner claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/mimalloc#1506 · 5 comments ·
Maintainers usually reply within 1 day
-
stale
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/mimalloc#1113 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/mimalloc#886 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
microsoft/mimalloc#368 · 1 comment ·
Maintainers usually reply within 1 day
All issues in microsoft/mimalloc
Similar issues
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
389ds/389-ds-base#8157 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
coolsnowwolf/lede#14305 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days