0
Answer

Memory Allocation/Deallocation

Radu Grosuleac

Radu Grosuleac

19y
2.3k
1
Hello. Well, this is my first post and it's kind of a stupid question that i want to ask. I am currently workning on an image processing program and i have to work on 200-1000 image files with this program. And the main drawback is that i may need to read the same file over and over again. So i thought : wouldn,t it be nice to load the file into memory as a MemoryStream and then read it from there instead (ram = fast, HDD=slow ) ( at 200 kb a file, there's no problem )? So i decided to make a class that stores the content of files (think of it as an array or a list of MemoryStreams ). I thought to have a maximum storage limit ( let's say 50 mb ). But what happens when you want to load more files into memory, but you exceed the storage space ? You have to unload the MemStreams that haven't been used for a long time ( or just once ). I tried and tried ( sounds like a Grimm story :)) ) and couldn't figure out how to unload them from memory. If you have any suggestion please help. I'm stuck. Well, thanks in advance.