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

Memory leak after unreasonable ammount of DrawOverlayInGame calls and large ImageElement #81

Closed
MarcellVokk opened this issue Dec 18, 2022 · 7 comments

Comments

@MarcellVokk
Copy link
Contributor

MarcellVokk commented Dec 18, 2022

Hi!

I've been using this library for a couple of days now, and I came across what I think is a realy small memory leak somewhere...
After calling the DrawOverlayInGame method for more than 70,000 times, a memory leak occurs, and becomes more noticable with each redraw...

At 50,000 redraws the memory usage of the target app is 205.4MB, but at 100,000 redraws, it jumps up to 555.1MB, and after that, it goes out of hand, and at 110,000 redraws the memory usage jumps to 1,2GB...
The overlay contains 1 image element, which is being changed every frame, and the size of it is 1920x1080...

I'd realy appreciate if someone could look into this, this is a realy cool library!

Thanks,
M

@MarcellVokk MarcellVokk changed the title Memory leak after unreasonable ammount of DrawOverlay Memory leak after unreasonable ammount of DrawOverlayInGame Dec 18, 2022
@MarcellVokk MarcellVokk changed the title Memory leak after unreasonable ammount of DrawOverlayInGame Memory leak after unreasonable ammount of DrawOverlayInGame calls Dec 18, 2022
@MarcellVokk MarcellVokk changed the title Memory leak after unreasonable ammount of DrawOverlayInGame calls Memory leak after unreasonable ammount of DrawOverlayInGame calls and large ImageElement Dec 18, 2022
@Lakritzator
Copy link

I'd advice you to read this issue: #80
@justinstenning just fixed a memory leak, and you should also make sure your code is working correctly.

@justinstenning
Copy link
Owner

@Vadkarika2 When you say redraw, do you mean sending a complete new overlay to the target?

Can you please provide a quick and simple reproducible snippet for the scenario?

@jazzup
Copy link

jazzup commented Dec 19, 2022

In my heavily modified version of this project, I wrap the code in DXSprite.cs -> BeginBatch(ShaderResourceView texSRV) with a using statement:

using (Texture2D tex = _batchTexSRV.ResourceAs<Texture2D>()) { Texture2DDescription texDesc = tex.Description; _texWidth = texDesc.Width; _texHeight = texDesc.Height; } _spriteList.Clear();

It eliminated one of a few leaks I encountered. My overlay changes each time I send it, and @justinstenning , I think this is what @Vadkarika2 is doing.

@MarcellVokk
Copy link
Contributor Author

Hi! Thanks for the help!

What I mean by redraw is I send a new overlay, yes...

I'll try out what @jazzup suggested, and post an update on the results!

Thanks again,
M

@MarcellVokk
Copy link
Contributor Author

Yep! This fixes my issue, thanks for the suggestion!

@MarcellVokk
Copy link
Contributor Author

I made a pull request (#82) where I fixed this memory leak using @jazzup's suggestion!

@justinstenning
Copy link
Owner

Merged, thx

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

4 participants