I've gotten past the point of functionality in my program, now I'm trying to optimize. When I started writing I was still learning about a lot of things, so I didn't quite do things the "right" way. Everything works, but I'm sure I could make it use less memory. I've been getting pretty conscious about this lately, so I've been opening up Task Manager and running my app, putting it through it's various functions to see how the memory is affected.
I've noticed that when I use images and open files, even after I close the filestream and binaryreader accessing the file, it still doesn't release the memory resources.
I have a program that opens a sort of archive file, a file containing a theme for the Xbox 360. The program reads all the information about the theme and lets the user preview individual files, save those individual files, and dump all the files. The theme file is only 12.5MB. My program's idle memory usage is just under 11MB. When I click the "Open" button to show the openFileDialog, the memory usage jumps to 21MB. When I actually open the theme file, it jumps up to just under 50MB of memory usage. Why is it going up 30MB just to open a 12.5MB file? There are various pieces of information I retrieve, and I loop through a 4096 byte block 64 times (reading 64 bytes at a time) to get the information about the individual files. I just create a byte array and pass it to a struct, then print the resulting information to a listView.
I'm sure I've disposed of all the things I can, but disposing my objects doesn't seem to release the resources. I have a "Close File" button that disposes and closes all the various files and readers and images I'm using, but the memory usage stays the same. Why is this?
Is there a simple way to optimize my program, and if there's no simple way, is there a way I can print some soft of debug info to the program telling me how much memory it's using and for what resources?
I've noticed that when I use images and open files, even after I close the filestream and binaryreader accessing the file, it still doesn't release the memory resources.
I have a program that opens a sort of archive file, a file containing a theme for the Xbox 360. The program reads all the information about the theme and lets the user preview individual files, save those individual files, and dump all the files. The theme file is only 12.5MB. My program's idle memory usage is just under 11MB. When I click the "Open" button to show the openFileDialog, the memory usage jumps to 21MB. When I actually open the theme file, it jumps up to just under 50MB of memory usage. Why is it going up 30MB just to open a 12.5MB file? There are various pieces of information I retrieve, and I loop through a 4096 byte block 64 times (reading 64 bytes at a time) to get the information about the individual files. I just create a byte array and pass it to a struct, then print the resulting information to a listView.
I'm sure I've disposed of all the things I can, but disposing my objects doesn't seem to release the resources. I have a "Close File" button that disposes and closes all the various files and readers and images I'm using, but the memory usage stays the same. Why is this?
Is there a simple way to optimize my program, and if there's no simple way, is there a way I can print some soft of debug info to the program telling me how much memory it's using and for what resources?
Comment