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

[Serious bug] Constant memory increase until crash when cache reaches capacity #39

Open
quinncnl opened this issue Dec 28, 2020 · 3 comments

Comments

@quinncnl
Copy link
Contributor

quinncnl commented Dec 28, 2020

Hi @merlos ,

I encountered a crash with MapCache while testing my app.

Reproduction

  1. Make sure cache is at capacity (e.g. 100MB)
  2. Scroll the map constantly for 10 sec

Then controlCapacity function constantly delete files, which is expected. However, memory usage is growing quickly without pausing, eventually leading to a crash. It's easily reproducible.

Below is a screenshot.

Screenshot 2020-12-28 at 18 13 46

First peak did not lead to crash. It's because there are not enough new tiles flushing out old ones (i.e. did not scroll the map long enough). Second peak crashed.

@NickAtGit
Copy link
Contributor

I don't see that in my app. I guess you should check your code for cycles...

@Frank-Peter
Copy link

Frank-Peter commented Oct 18, 2022

I can confirm the observation of strongwillow. Same behaviour in my app.

A (not so nice) workaround for me is to clear the cache when I get a memory pressure warning from the OS. At least that seems to work.

@Frank-Peter
Copy link

The problem lies in the excessive call to FileManager.default.contentsOfDirectory when the cache is full. DiskCache creates the ordered list of URLs in the cache over and over again for every tile to throw out. It would be better to create such a list at startup and keep it up to date during all operations. I've done that experimentally it it works quite nicely. If anybody is interested, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants