API Question Vessel Cleanup never called?

Vash

OHM Administrator
Joined
Mar 26, 2008
Messages
189
Reaction score
2
Points
0
Location
In a cave, of course.
Website
www.orbithangar.com
Maybe it's just me, but as far as I can tell, my vessel's destructor is never being called. The reason why I say this is that I have allocated a few texture resources using oapiLoadTexture. If I change those textures in my vessel dll and completely restart orbiter, the old textures still load in-game. It is not until several more loads/unloads that the new textures finally appear. I have the following code in my vessel class:

Code:
Rifter::~Rifter(){
    MessageBox(0,"test","test",0);
    oapiDestroySurface(drawExhaust);
    oapiDestroySurface(exh1);
    oapiDestroySurface(exh2);
}

DLLCLBK void ovcExit (VESSEL *vessel)
{
    if (vessel) delete (Rifter*)vessel;
}
With the messagebox code there, the messagebox never appears. I have also tried compiling a debug version and debugging it while running. I can set breakpoints in the main code and they get hit just fine, but if I put a breakpoint in the ovcExit and/or destructor, it never gets hit!

All I am doing is starting orbiter, loading a scenario with only my vessel in it, and then ctrl+q, and then exiting the program completely. During all of this (as far as I can tell), the destructor is never called! Am I missing something here?

And yes, I do have the destructor defined in the public section of my class definition. Any ideas?

EDIT: I may have been doing something funny with my compiling and such (it's getting late over here). But I am still clueless on why a breakpoint in the destructor always fails to be hit.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
All I am doing is starting orbiter, loading a scenario with only my vessel in it, and then ctrl+q, and then exiting the program completely. During all of this (as far as I can tell), the destructor is never called! Am I missing something here?

Did you try to switch from fast-shutdown to deallocate-memory option in Orbiter's extra tab?

I remember something coming from there during my researches for Orbiter.NET...

regards,
Face
 

DarkWanderer

Active member
Orbiter Contributor
Donator
Joined
Apr 27, 2008
Messages
213
Reaction score
83
Points
43
Location
Moscow
Can you transfer texture management to InitModule/Exit module (and share it between ships)?
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
I can confirm the same behaviour as Vash reported. ovcExit does not get called when exiting the simulation session. It does get called if the vessel is deleted during sim. It also gets called if you switch from "Respawn Orbiter Process" (aka fast-shutdown) to "De-allocate memory" per Face's suggestion.

Is calling ovcExit not required when using the "Respawn Orbiter process" or "Terminate Orbiter process" options because killing the Orbiter process trashes its page table and it starts fresh with a new one when it is respawned? Hence the "fast shutdown" moniker, because all the deallocations don't need to occur?
 

dbeachy1

O-F Administrator
Administrator
Orbiter Contributor
Addon Developer
Donator
Beta Tester
Joined
Jan 14, 2008
Messages
9,217
Reaction score
1,563
Points
203
Location
VA
Website
alteaaerospace.com
Preferred Pronouns
he/him
Is calling ovcExit not required when using the "Respawn Orbiter process" or "Terminate Orbiter process" options because killing the Orbiter process trashes its page table and it starts fresh with a new one when it is respawned? Hence the "fast shutdown" moniker, because all the deallocations don't need to occur?

That is correct. The Orbiter process exits immediately and Windows frees up all memory and resources allocated by the Orbiter process all at once. Individual object destructors are not invoked, which is why the shutdown is so fast. The shutdown performance difference is quite dramatic when you are running high-res textures like level 10.
 
Top