Originally my game uses sprites/textures exported for 1080p and recently I added support for a high resolution sprite option (4K). I noticed that after a while the game always crashes when trying to load a random texture. I can get the crash to happen almost consistently when entering the final boss area of my game (since it loads quite a lot of large textures in a row there). The game doesn't appear to be using very much memory at all when it crashes and the textures are still quite a lot smaller then the GPU's max texture size, so I'm not sure what the problem is.
The crash is generally from a LoadingFailedException but it also sometimes throws a SEHException:
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in sfmlnet-graphics-2.dll
External component has thrown an exception.
An unhandled exception of type 'SFML.LoadingFailedException' occurred in sfmlnet-graphics-2.dll
Failed to load texture from memory
I've gotten a few LoadingFailedException (failed to load texture) crash reports from users in the past as well (using the normal 1080p graphics).
The game loads the textures in via MemoryStreams (extracted from uncompressed zip files) but I also tested loading from filenames and the problem persisted.
Has anyone else had problems like this and/or know how I could fix this?