microsoft / microsoft/mimalloc
How to redirect the output of mimalloc to a file?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
Hi, may I output these mimalloc's infomation to a file?
```
mimalloc: option 'show_errors': 1
mimalloc: option 'show_stats': 1
mimalloc: option 'eager_commit': 1
mimalloc: option 'eager_region_commit': 0
mimalloc: option 'reset_decommits': 0
mimalloc: option 'large_os_pages': 0
mimalloc: option 'reserve_huge_os_pages': 6
...
```
Looks like I can use `mi_register_output`:
```
mi_output_fun(*output_handler) = [](const char* msg, void* arg)
{
// output to a file named "mimalloc.log"
FILE* fp;
if (0 != fopen_s(&fp, "mimalloc.log", "a"))
{
fprintf(fp, "%s\n", msg);
fclose(fp);
}
};
mi_register_output(output_handler, nullptr);
```
But it will open/close the file every time when mimalloc flushes the buffer, which may harm the performance. Could you please provide a demo on how to use it?
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start with the mi_register_output API and the output-buffer behavior described in the issue. Provide a focused usage example for writing mimalloc output to a file without reopening it for every flush; done when the example addresses the performance concern and can be followed by users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- performance
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100