C
C#2w ago
wickend

Application runs out of memory after compressing many images

Im working on a side project to create a archive and im stumped at this one problem, i didnt encounter this problem before and i need to ask it here, the main issue is in ImageGrabber but i would appreciate if you would spot other bugs https://github.com/wick3nd/SEP-packager/blob/main/src/SEP%20packager/ImageGrabber.cs
GitHub
SEP-packager/src/SEP packager/ImageGrabber.cs at main · wick3nd/SE...
SteelEngine Package packager is a file compressing program for a in progress game engine - wick3nd/SEP-packager
11 Replies
wickend
wickendOP2w ago
it happens when i try to compress 3k images stolen from a game but it stops after 1.7-2k images compressed
JP
JP2w ago
zero clue if its the cause of your problem, but that ImageGrabber should probably either have all non-static fields, or should pass those values as parameters to ImageHeader/ImageDataStream, instead of using fields (if you want everything to be static) -- that way it's fully impossible for simultaneous invocations to affect one antother
wickend
wickendOP2w ago
making the whole class non static doesnt fix the problem, either does lowering the zstd compression level even if i close every single program the issue doesnt stop
JP
JP2w ago
I'm fairly confident I've solved nothing, but Here's the little bit I rearranged as I was walking through. can PR if you want (or feel free to just take/leave stuff on your own): https://github.com/wick3nd/SEP-packager/compare/main...John-Paul-R:SEP-packager:jp-thoughts?expand=1
JP
JP2w ago
you might get use out of some sort of memory snapshotting/profiling to see what exactly is leaking memory (or at least what types of objects): https://www.jetbrains.com/help/rider/Attach_to_and_profile_.NET_processes_memory.html#dm-run-a-profiling-session
JP
JP2w ago
(there are other tools as well, naturally) c# memory snapshot
c# memory snapshot at DuckDuckGo
DuckDuckGo. Privacy, Simplified.
wickend
wickendOP2w ago
i tested it and i need to tell you that it didnt solve anything unfortunately but its surely cleaner in some places
JP
JP2w ago
oh, and thanks for responding to my comments in the follow up commit, I see what you were going for. Of course, feel free to remove mine if they're now irrelevant.
wickend
wickendOP2w ago
i have changed a few files and made some things use spans but it didnt do anything i hate this thing, god damn:catfine:
JP
JP2w ago
Do you have a place I can get the files to use as input? Happy to give the thing a whirl locally
wickend
wickendOP2w ago
you could put some random images to it and maybe it would produce same results just make an image and copy paste it a few thousand times

Did you find this page helpful?