<thebolt> Xordan: DeleteAll _does_ remove all _engine_ references
<Xordan> So?
<thebolt> it is all it can do
<Xordan> That's not what it's supposed to do
<Xordan> At least, "Delete all entities in this region." doesn't translate to that for me
<thebolt> well, it is in the engine, if you as an app (or another plugin) keep a reference to it it cannot delete it
<thebolt> it would create stale pointers
<Xordan> That's not true. Most of the things that are holding references are also being deleted, so their references are freed
<thebolt> yes
<Xordan> Of course if something in PS is holding a reference then it shouldn't be deleted, which is the point of ref counting
<thebolt> but what i mean is, DeleteAll removes all references held by the engine
<thebolt> and as long as you don't have circular references (which we shouldn't have for other reasons too) then all references that are removable will be removed
<Xordan> Except that doesn't happen
<thebolt> well, then the question is why?
<thebolt> what in engine is keeping references?
<Xordan> Because references are held in other places which are never removed, even if they should be
<thebolt> what other places?
<Xordan> materiallist, texturelist
<Xordan> those kinds of places
<Xordan> sector
<Xordan> Which is what I want to do, restructure this so the engine cleans itself (which is a nicety, not a requirement), and do a 'search and remove' on these places to free the reference
<thebolt> it already does remove materials from materiallist
<thebolt> textures from texture list etc
<Xordan> Where?
<thebolt> DeleteAll calls engine->RemoveObject on all objects
<Xordan> That doesn't do that
<thebolt> which in turn calls SelfDestruct on the object
<thebolt> The code says it does
<Xordan> The print says it doesn't
<thebolt> if it doesn't, then you should trace code to see why not
<thebolt> atm i think it is more likely your printfs are wrong than the code not working ;)
<Xordan> They aren't my printfs
<Xordan> Not Deleted 133807FC 'lightw37.jpg' ref=2 etc.
<Xordan> for almost every single object
<thebolt> well, i think there must be something external holding for example a reference to the sector
<Xordan> and my memory usage shows that those aren't incorrect.
<thebolt> then that will hold pretty much the entire chain alive
<thebolt> put a breakpoint and trace the code and you'll see
<Xordan> Well, the sector has a refcount of 10 after removing it from the region
<Xordan> also, after removing the sector manually those things still aren't removed
<thebolt> well, if the sector have a refcount of 10, of course the lights won't be removed, same for mesh, material etc etc
<Xordan> Also, calling self destruct on every object with a ref held by the region is quite incorrect, because it might be shared with another region
<thebolt> Xordan: well, RemoveObject is supposed to remove it from engine entirely
<thebolt> also, an object can just be in one region
<Xordan> No it can't
<thebolt> note, selfdestruct won't _kill_ the object
<thebolt> it will remove it from materiallist for example
<thebolt> but if there is a mesh still holding a reference to it that will still hold a reference
<thebolt> what cant?
<Xordan> I discussed that with res a while ago and we agreed it was more correct to allow multiple regions to hold a ref to the same object, also because that's kind of required to reduce duplication.
<thebolt> Xordan: yea, problem is that object only hold one parent pointer
<thebolt> so it can only remove itself from one
<Xordan> Shouldn't it be the job of the parent to remove the child? Not vice versa
<Xordan> For cleaning up purposes anyway
<thebolt> well, when you say "RemoveObject" (for example) it has to find the parent of the object to be able to remove it from the parent
<thebolt> i would not go changing the csObject parenting structure without some serious thinking and discussion
<Xordan> That's not too good a method, because it breaks when you want to share an object.
<thebolt> no, but you cannot just change such stuff without any discussion
<thebolt> and to review all cases where the assumption is now made
<Xordan> Well, we should probably discuss this again with jorrit and res are around, or I can paste this into a reply of that email and we can discuss it on the ML
<Xordan> Atm everything works as it has for a while (doesn't really work), so we can work out exactly what to do before making any more changes.