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

Fix memory overflow in debugger for select targets #3265

Closed

Conversation

ACrazyTown
Copy link
Contributor

@ACrazyTown ACrazyTown commented Oct 13, 2024

Because openfl.System.totalMemory is an Int, after reaching ~2.14GB (32bit int limit) the memory usage will overflow and no longer display accurate values:
Screenshot 2024-10-13 192013
On Hashlink and the C++ targets we can get a more precise 64bit memory usage value, which allows us to display way higher values (and this isn't even close to the limit):
Screenshot 2024-10-13 193424

Unrelated: I wonder if it'd be worth it to use FlxStringUtil.formatBytes() here

@ACrazyTown
Copy link
Contributor Author

should flash.system.System.privateMemory be used instead on Flash? I'm doing a test where I clone a bunch of bitmaps to get the memory usage up, totalMemory keeps hovering around 150mb but privateMemory seems to provide an an accurate number, the same one like in task manager

@Geokureli
Copy link
Member

should flash.system.System.privateMemory be used instead on Flash? I'm doing a test where I clone a bunch of bitmaps to get the memory usage up, totalMemory keeps hovering around 150mb but privateMemory seems to provide an an accurate number, the same one like in task manager

https://airsdk.dev/reference/actionscript/3.0/flash/system/System.html

privateMemory : Number
The entire amount of memory (in bytes) used by an application.

totalMemory : uint
The amount of memory (in bytes) currently in use that has been directly allocated by Flash Player or AIR.

At a glance, totalMemory seems like the right choice, as in it seems like the true memory usage allocated to run the program.

though privateMemory is a number

@ACrazyTown
Copy link
Contributor Author

At a glance, totalMemory seems like the right choice, as in it seems like the true memory usage allocated to run the program.

What confused me is that in my tests where I just clone a bitmap a bunch of times, totalMemory reports something around 150mb that never seems to grow at all:
image
While in task manager I had ~5gb of usage:
image

Maybe I just don't understand what "directly allocated by Flash Player or AIR" means

though privateMemory is a number

There's also totalMemoryNumber, haxe api says it requires flash 10.1, I assume this is compatible with Flixel?

Now that I think about it maybe I should just PR these changes to OpenFL and add totalMemoryNumber there?

@Geokureli
Copy link
Member

Now that I think about it maybe I should just PR these changes to OpenFL and add totalMemoryNumber there?

Not a bad idea

@ACrazyTown ACrazyTown closed this Oct 14, 2024
@ACrazyTown
Copy link
Contributor Author

ACrazyTown commented Oct 14, 2024

My PR in OpenFL was merged, I'll make a new one here once I figure out the conditionals

@Geokureli
Copy link
Member

Please link the OpenFL issue heere as well as in the new PR, thanks!

@ACrazyTown
Copy link
Contributor Author

Please link the OpenFL issue heere as well as in the new PR, thanks!

openfl/openfl#2744

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

Successfully merging this pull request may close these issues.

2 participants