0

Hey,

I use openfiledialog to load a file as so:

OpenFileDialog^ ofd=gcnew OpenFileDialog;
 ofd->Filter="Monitor files (*.hmc)|*.hmc";
 ofd->FileName="";if(ofd->ShowDialog()==System::Windows::Forms::DialogResult::OK){
	 loadFile(ofd->FileName);
 }

when i initially run the program memory in task manager is about 10,000K. when this code runs it jumps to 17,000K and doesnt go back down. I tried using delete and im 100% sure its the openfiledialog's call to showfiledialog... how do i deallocate this memory?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Narue
0

It all depends on your compiler's memory allocation algorithms. Some compilers to not return deallocated memory to the operating sytesm; instead they keep it so that it can be reused.

0

>I tried using delete
That only marks the object as ready for garbage collection. It doesn't actually release anything until the garbage collector runs on the same generation. Even when the garbage collector runs, that doesn't mean your process' footprint will go down. The memory might remain allocated for faster creation of future objects within your process.

>how do i deallocate this memory?
You don't. It's managed by the .NET framework. All you can do is mark it for garbage collection and force the garbage collector with GC::Collect() (the latter generally being a bad practice).

Edited by Narue: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.