Skip to Content
0

Autoinstantiate, destroy not working

Jan 17 at 05:14 PM

101

avatar image
Former Member

Hi guys.

I have a regular NVO (call it NVO1) that has an autoinstantiate NVO (lets call it NVO2) as an instance object. This autoinstante nvo opens a connection to the DB on its constructor, and calls a disconnect on its destructor.

// Sample:
NVO1 >> instance variables: NVO2 iuo_2
NVO2.constructor: connect;
NVO2.desctructor: disconnect;

My code:
NVO1 luo_1
// At this moment, I have only 1 connection open to the DB

luo_1 = Create NVO1
// Now I have 2 connections open, because of the autoinstantiate of it's instance nvo. All good.

Destroy luo_1
// Here's the thing, it didn't disconnect. The connection remais open.
// Only when I close the application the connections are closed. Even calling GarbageCollect does not help.
// This sample code is used in a loop, so I'm reaching "maximum number of connections" on the DB server rather quickly. I'm on PB12.5.

Any thoughts on this? The changes to rebuild NVO2 will be substantial. :(

10 |10000 characters needed characters left characters exceeded

I cannot reproduce this behaviour in V12.6 Build 4139.

0
Former Member

Thanks Chris, I'll check if we can upgrade.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Chris Pollach Jan 19 at 09:00 PM
0

Hi Daniel;

This is normal PBVM behaviour and not a bug. Most people do not realize that when you use the Auto-Instatiate (AI) feature, the PBVM issues a create for the object but does not destroy the object right away when the parent is destroyed. Instead, the PVBM only "marks" the AI object as a "potential" to destroyed and then carries on its merry way - leaving the AI object instantiated. If the AI object is used frequently ( and here is the PBVM's thought ) - then why not leave it instantiated in the class pool (even though its "to be deleted" ) so that I can just reuse its pointer and save the instantiation process. Thus, better performance.

The AI "to be deleted" object pile is only actioned by the PBVM when the entire App is minimized. So most likely, you are getting caught in the AI normal behaviour trying to out-think your App for better performance. The best approach in this implementation is to not use the AI feature for this processing and do the CREATE and DESTROY implicitly from the parent object.

HTH

Regards ... Chris

Share
10 |10000 characters needed characters left characters exceeded