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

drawDebug massive memory leak #3285

Open
mikaleerhart opened this issue Nov 15, 2024 · 6 comments
Open

drawDebug massive memory leak #3285

mikaleerhart opened this issue Nov 15, 2024 · 6 comments

Comments

@mikaleerhart
Copy link

mikaleerhart commented Nov 15, 2024

  • Haxe version: 4.3.6
  • Flixel version: 5.8.0
  • OpenFL version: 9.4.0
  • Lime version: 8.2.1
  • Affected targets: html5

Code snippet reproducing the issue: FlxG.debugger.visible = true; FlxG.debugger.drawDebug = true;
(You have to use lime test html5 -debug to reproduce.


Observed behavior:
386408317-b49a87a7-daf7-4c91-8c36-328351eb2bf7

I've been porting my game from Phaser to flixel and ran into a memory leak in the html5 target. (thought it was lime but we narrowed it down to flixel in this issue. If you need private access to my repo to reproduce let me know. The leak was confirmed by another user in previous issue and they directed me here for further invesigating.

@mikaleerhart mikaleerhart changed the title HTML5 target memory leak drawDebug massive memory leak Nov 22, 2024
@mikaleerhart
Copy link
Author

Update: it's happening on Android too. It's making it almost impossible to debug hitBoxes in my game on different devices.

@ACrazyTown
Copy link
Contributor

Might be related: #3168

@Geokureli
Copy link
Member

Has anyone done any profiling, yet?

@Geokureli Geokureli added this to the 5.9.0 milestone Nov 25, 2024
@Geokureli
Copy link
Member

Geokureli commented Nov 25, 2024

Possibly related: openfl/openfl#1883
@mikaleerhart Can you try the example in this issue and see if the memory leak is there, even when flixel is not used?

@Geokureli
Copy link
Member

I tried the issue I linked, no memory leaks found.

I tried the following on html5, I waited a while and memory stayed within the same bounds for about a half hour.

package states;

import flixel.FlxG;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.math.FlxRect;
import flixel.util.FlxColor;

class DebugSelectionTestState extends flixel.FlxState
{
	static inline var SIZE = 16;
	
	final sprites = new FlxTypedGroup<FlxSprite>();
	
	override function create():Void
	{
		super.create();
		
		add(sprites);
		createMess(2.0, true);
		
		// scroll to center of mess
		FlxG.camera.scroll.x = FlxG.width / 2;
		FlxG.camera.scroll.y = FlxG.height / 2;
		
		#if FLX_DEBUG
		FlxG.debugger.drawDebug = true;
		FlxG.debugger.visible = true;
		#end
	}
	
	function createMess(density = 0.5, sortColors = true)
	{
		final area = FlxRect.get(0, 0, FlxG.width * 2, FlxG.height * 2);
		var count = Std.int(area.width * area.height / (SIZE * SIZE) * density);
		while (count-- > 0)
		{
			final sprite = sprites.recycle(()->new FlxSprite());
			sprite.makeGraphic(SIZE, SIZE);
			sprite.x = FlxG.random.float(area.left, area.right - SIZE);
			sprite.y = FlxG.random.float(area.top, area.bottom - SIZE);
			final hue = 60 * FlxG.random.int(0, 6);
			sprite.color = FlxColor.fromHSB(hue, 1, 1);
		}
	}
}

Can you try the above code and let me know if that causes the memory issue on your machine?

If not, we need to learn more about your project, what kind of debug drawing are you doing? if you disable debug drawing on specific things (via mySprite.ignoreDrawDebug = true;) does that prevent the leak? Use that to narrow it down to specific sprites

@Geokureli Geokureli modified the milestones: 5.9.0, Next Patch Dec 1, 2024
@Geokureli
Copy link
Member

I can't do much about this until we learn more about this and how to reproduce it locally. I'm taking it off the 5.9.0 release. If anyone has more info please let us know

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

No branches or pull requests

3 participants