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?

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.

>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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.