Board index » cppbuilder » dynamic forms and memory leaks

dynamic forms and memory leaks


2004-11-07 08:11:09 PM
cppbuilder25
Buy, it's sure hard keeping up with all the posts here.
Does anyone know if I create a form at run-time (with new), I assume I need
to keep track of it and send a message back to its parent to delete the
memory. I'm asking on the off chance that the built-in close routines
handle deleting the memory anyway.
Thanks,
Greg
 
 

Re:dynamic forms and memory leaks

Greg,
If you create a form runtime, you have to pass the owner of the form in the
constructor. (Most likely another form).
This owner will take care of the cleanup. For instance when you create one
within a another form:
TMyForm *dynamic_form;
dynamic_form = new TMyForm(this);
Jeroen Plaisier
"Greg Bryant" < XXXX@XXXXX.COM >schreef in bericht
Quote
Buy, it's sure hard keeping up with all the posts here.

Does anyone know if I create a form at run-time (with new), I assume I
need
to keep track of it and send a message back to its parent to delete the
memory. I'm asking on the off chance that the built-in close routines
handle deleting the memory anyway.

Thanks,
Greg
 

Re:dynamic forms and memory leaks

"Jeroen Plaisier" < XXXX@XXXXX.COM >wrote in
Quote
Greg,

If you create a form runtime, you have to pass the owner of the form
in the constructor. (Most likely another form).
This owner will take care of the cleanup. For instance when you create
one within a another form:

TMyForm *dynamic_form;
dynamic_form = new TMyForm(this);

Jeroen Plaisier

"Greg Bryant" < XXXX@XXXXX.COM >schreef in bericht
news: XXXX@XXXXX.COM ...
>Buy, it's sure hard keeping up with all the posts here.
>
>Does anyone know if I create a form at run-time (with new), I assume
>I
need
>to keep track of it and send a message back to its parent to delete
>the memory. I'm asking on the off chance that the built-in close
>routines handle deleting the memory anyway.
>
>Thanks,
>Greg



Thanks. I also just found the following in the Developer's Guide
(talking about creating numerous child windows on the fly):
"To prevent the application from leaking memory, we need to ensure that
the memory is properly freed when each [child window] is closed. Select
the "ChildForm" in the Object Inspector. Switch to the Events tab and
double-click the OnClose event to create the OnClose event handler.
Insert the following code into the event handler:
Action = caFree;
"
That's much easier than what I was thinking.
Greg
 

{smallsort}