Fix rendering resource cache capacity#18
Merged
EMaksymenko merged 1 commit intoWorldWindEarth:developfrom Oct 22, 2019
EMaksymenko:fix/invalid-resource-cache-capacity
Merged
Fix rendering resource cache capacity#18EMaksymenko merged 1 commit intoWorldWindEarth:developfrom EMaksymenko:fix/invalid-resource-cache-capacity
EMaksymenko merged 1 commit intoWorldWindEarth:developfrom
EMaksymenko:fix/invalid-resource-cache-capacity
Conversation
…e memory in render resource cache capacity calculation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
Fixed recommended capacity of render resource cache calculation.
Currently render resource cache capacity is calculated using some magic numbers based on total device memory capacity. Using this approach any device with 2GB RAM use 384Mb of resource cache.
But total memory and available application heap are not the same. For example, Samsung Note 9 has 6GB of device RAM, but only 256Mb heap available for each application in standard mode and 512MB in "largeHeap" mode. As you can see 384Mb cache size is much bigger than 256Mb available heap, which cause application crash during intensive use, when cache reaches its capacity limit.
https://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android
Why Should This Be In Core?
This issue is the reason of application crash on many devices with large amount of memory.
Benefits
Fix application crash.
Potential Drawbacks
Incorrect multiplication coefficient may be used, which cause ineffective memory usage on some devices.
I have selected coefficient magic number = 0.75, but in some cases if application itself use very few amount of memory it may ineffectively use available heap, in other hand if application is very heavy and use more then 25% of heap, it may cause memory overflow and crash.
Applicable Issues
Closes #19