|
|
|
|
|
by keanebean86
2612 days ago
|
|
I'm a moron and did something stupid not too long ago that would be perfect for this. I'm too lazy to find my actual code but here's the gist: C# but might working in Java/etc too * Create an Image of some size loop hight of image loop width of image
Bitmap b = cast Image to bitmap since Image doesn't have the pixel method
get pixel value or whatever looks legit
end
endThis creates a new bitmap for EVERY pixel in the image. If the image is large enough and the system is 64 bit bad things happen. On Lubuntu this code burned through 8 GB of ram in seconds and was well on its way to eating all the virtual memory before I forcefully shut it off. Maybe this is a Linux issue but it hard locked my system. I couldn't switch to a different terminal or anything. |
|
The only thing I can think of is that the actual bitmap data is not tracked as a managed array by a Bitmap instance, but rather is a pointer or handle from some underlying native library. GC might not kick in then, because it doesn't realize how much memory all those bitmap objects are actually hogging. Now, on .NET, when libraries do that kind of thing, they're supposed to use GC.Add/RemoveMemoryPressure to let it know. But perhaps the library that you were using didn't?