Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minetest on Linux (glibc) is not able to give back freed MapBlocks to the OS #14645

Open
RonnyBarthmann opened this issue May 13, 2024 · 6 comments · May be fixed by #14707
Open

Minetest on Linux (glibc) is not able to give back freed MapBlocks to the OS #14645

RonnyBarthmann opened this issue May 13, 2024 · 6 comments · May be fixed by #14707
Labels
Bug Issues that were confirmed to be a bug Linux Upstream issue This bug is the fault of a library, the OS or an external service we use.

Comments

@RonnyBarthmann
Copy link

Minetest version

all Minetest versions till 5.8.0 tested

Irrlicht device

No response

Operating system and version

debian and all debain based

CPU model

all models

GPU model

not importan / also a problem on servers (headless)

Active renderer

not importan / also a problem on servers (headless)

Summary

https://forum.minetest.net/viewtopic.php?t=30509

minetest dont free memory because of fragmentation like on windows
so minetest builds up a huge amount of RAM and never free any of it

Steps to reproduce

start a minetest server and keep it running for days
or start a world and user "emergeblocks" to load a huge amount of blocks ... after it finishes it never goes down again

@RonnyBarthmann RonnyBarthmann added the Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible label May 13, 2024
@sfan5 sfan5 changed the title ⛔ [RAM overflow / Memory leak] Probably bug Minetest on Linux (glibc) is not able to give back freed MapBlocks to the OS May 13, 2024
@sfan5 sfan5 added Bug Issues that were confirmed to be a bug Upstream issue This bug is the fault of a library, the OS or an external service we use. Linux and removed Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible labels May 13, 2024
@sfan5
Copy link
Member

sfan5 commented May 13, 2024

As we already found out here and in the linked forum thread, this isn't a bug in Minetest itself, but glibc (and they don't seem to care either).
The next best thing we could do it work around it.

@RonnyBarthmann
Copy link
Author

I thought the problem was that glibc doesn't trim automatically...
Can't you just call the trim function?
Maybe with a compile-if so that it is only done under Linux

@savilli
Copy link
Contributor

savilli commented May 16, 2024

We can't because the performance penalty of that solution is unclear. The execution time of the trim function depend on many factors, therefore it may work very slowly under certain conditions. Fixing one corner case by creating another one doesn't sound like a good idea.

@RonnyBarthmann
Copy link
Author

but it wouldn't be a problem to offer something like that as an option under the advanced settings...
firstly, you could find out over time whether it has disadvantages and even if it does,
people can then decide for themselves whether the advantages outweigh the disadvantages

I think it would be worth a try

@sfan5
Copy link
Member

sfan5 commented May 17, 2024

We should take care not to call malloc_trim too often, but this is not a reason to avoid this entirely.
My idea: Very coarsely track how much memory has been freed, once that number crosses (e.g.) 128MiB call malloc_trim once, reset counter to zero.

@Desour
Copy link
Member

Desour commented May 17, 2024

Another solution would be to use a global synchronized_pool_resource for allocating mapblocks. Either it already allocates big enough memory chunks from the upstream allocator (i.e. bigger than glibc's M_MMAP_THRESHOLD mallopt), or if not, we can supply an upstream allocator that just uses mmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug Linux Upstream issue This bug is the fault of a library, the OS or an external service we use.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants