Why IBConnection component looses its information about the default SQLTransaction component after first run?
It is not a bug it is by design.
Are you sure?
97% sure yes.
When TSQLtransaction frees it self all controls that registered with its destruction mechanism are informed so they can react. TIBConnection at that point cleans up the internal field to avoid random memory access errors.
I have destroyed and recreated the form, how is the information present on the first instance, but it just does not exist on next instances?
It worked correctly on first run. Why it does not run correctly after destruction and recriation?
The first time it is executed, the settings where loaded from the lfm resources, and I assume some sort of delayed assignment is setup(I do not remember the exact details how this works you need to verify it).
The Transaction's onDestroy even has not been executed yet, after form2 is created the delayed assignment is executed and the link is now complete.
When the the Teansaction is destroyed as a result of the caFree action, the connection gets informed and reacting on the event it destroys any and all links to a dead object, subsequent call to TForm2.Create do not have any info to link the two components again.
The mechanism is used primarily on the IDE designer when you delete a linked transaction all objects that are linked to it are informed and instead of a SigSegV error they clean up their internal fields. For that I'm 100% sure.
Try to change the onclose action to caHide instead
What will hapen to memory if I don't destroy objects all day long?
I can not answer that, I can only say that if care is taken to close the queries in the onclose event then the used memory should not change that much except if there are memory leaks somewhere.
or even better do not use the form2's transaction as the default transaction of the database
Revisit the sample project. Form2's transaction is not the default transaction of the connection.
Yes it is, see attached image.
use it only as the transaction of the queries on form2.
It already is.
then why you need it to be the default transaction of the connection?