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

Free Memory not matching well with what device claims #8

Open
corepuncher opened this issue May 29, 2024 · 7 comments
Open

Free Memory not matching well with what device claims #8

corepuncher opened this issue May 29, 2024 · 7 comments

Comments

@corepuncher
Copy link

Hello. Perhaps this is just a misunderstanding on my part but I have the following:

int freePhysicalMemory = SysInfo.getFreePhysicalMemory();

I get a value of 1.4 GB (profile mode)
and (0.8 GB in debug mode).

But if I minimize the app and go into memory settings (Galaxy S23_+), it shows the following:

2.9 GB available,
4 GB used
1.1 GB reserved

And prior to the app running, the device shows 3.4 GB available.

I'm trying to maximize the "safe" amount of memory to use in my app for caching data before clearing the cache.

Currently the values are too low it seems compared to what it "could" be using. Any advice on this? Thank you!

@dev-kasibhatla
Copy link

dev-kasibhatla commented Nov 13, 2024

The package is showing unused memory instead of available memory.

Device settings and most apps typically display available memory, which is the amount that can be reclaimed for use. Unused memory refers to memory that isn't currently occupied but isn't necessarily available for allocation.

Available memory is the more relevant value in most cases.

Screenshot 2024-11-13 at 19 33 41

@dev-kasibhatla
Copy link

@corepuncher in the interest of time, I have forked and added a new method: getAvailablePhysicalMemory()
On Linux and Android platforms, this will correctly return the expected of value of RAM that can be used (rather than RAM that is unused)

After testing on 3 different Android devices, I can confirm it exactly shows the available RAM equal to what other "diagnostic apps" on PlayStore show.

I have also uploaded it to pub.dev (https://pub.dev/packages/system_info3)

@corepuncher
Copy link
Author

This will be very helpful! Your work is very much appreciated.

For iOS, I wonder if I could make an educated guess, based on the model of the device perhaps.

@dev-kasibhatla
Copy link

That might be your only way for now.

From my brief review of the package code, iOS has limited support (if any), with most functions implemented for Android, Linux, Windows, and macOS. That's why I removed iOS as a supported platform on pub.dev.

While I add more relevant functionality to the package, I’ll look into iOS implementation also. Any help is appreciated :)

@bsutton
Copy link
Collaborator

bsutton commented Nov 14, 2024

If you post a pr I will publish it.

@dev-kasibhatla
Copy link

Hi @bsutton
Since I noticed the package hadn't been updated in 18 months, I forked the repo and made several updates (to metadata, README, name, etc.), then republished it. I'll create a branch compatible with this repo by cherry-picking the relevant changes and submit a PR. Thanks

@bsutton
Copy link
Collaborator

bsutton commented Nov 14, 2024 via email

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