DirectoryInfo dir =
new DirectoryInfo(mydir);foreach (FileInfo f in dir.GetFiles("*.std"))
{
// Create a filestream for our new file.
FileStream fs = s.file_open(f.FullName); // calls a simple method that opens a filestream object. // Determine the length of the filestream, and create the appropriate variables.
double tmp_length = fs.Length;
int length = (int)tmp_length;
byte[] byteArray = new byte[0];
string PART_TYP = null;
byteArray = new byte[length];
fs.Read(byteArray, 0, length);
fs.Close();
for (int j=0; j
// Go do some stuff with this binary data...
}
}
So, my question is, after my for loop, how do I "clean up" the byteArray array. I've tried calling GC.Collect() and that has no effect. After a couple of files, VS throws an out of memory error and because the process is using all the RAM.
This is probably a really easy question, I've just never dealt with memory allocation before.
Thanks a lot!
AnttiPosted Dec 14, 2005, 1:32 AM
twistedJPPosted Dec 14, 2005, 1:27 AM
I do this when killing the array;
ByteArray = new Byte[]{};
ByteArray = null;
Just a suggestion.
Larry
AnttiPosted Dec 9, 2005, 2:47 AM
tylerstaszakPosted Dec 8, 2005, 2:05 PM
AnttiPosted Dec 8, 2005, 1:40 PM
byteArray = null;Usually you should check if a class implements IDisposable interface; when class does that, it has Dispose-method that enables eplicit object disposion (not the case with Array class).
        //is "disposion" even a word?;)