My Delphi 7 program uses an OCX to control some hardware. I don't have any sample code so I am working through loading/using/unloading the control correctly. Unfortunately, if I use the hardware and load the OCX, the main process will not completely quit when the application closes.
If I use the hardware, the OCX loads and everything works fine. On the program closing, the OCX doesn't unload properly and my program doesn't close completely. It leaves a small 24 meg footprint in memory that can only be seen in Task Manager.
If I rerun the program, everything works perfectly including the hardware. If I use the hardware and then close the program, it leaves another 24 meg footprint. Rinse and repeat.
Until I can get the OCX code working correctly, if there anyway I can "force" the unloading of the OCX control for now? Or force the termination of the process?
views:
184answers:
3An OCX control is like a dll. It unloads one way or the other when the process is terminated. Windows reclaims all memory when a process is closed. Where do you see this memory? Only is this program called Activity Monitor? Could it be that that program is incorrect?
UPDATE: After the new information you gave it is clear it is not about freeing memory, but about a process not being closed/terminated.
This could happen if some threads are still running. The 3rd party control might creat threads and has not terminated them yet. This might be a bug or maybe you have to call some finalize/uninitialize/dispose/close method on the 3rd party control?
Try running the program under the debugger, with breakpoints in all your unit finalization sections and in any OnClose methods you have. If you have a form with no OnClose method, add one. Then watch as the application terminates and see how far you get.