Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
warrens
Beginner


Joined: 23 Aug 2002
Posts: 10
Location: Canada

PostPosted: Fri Aug 13, 2004 1:34 am   

Unloading COM objects. How?
 
I'm developing a COM component which I intend to use from Zmud. Everything works fine with it, except that ZMud doesn't seem to have a facility for disposing of a COM object.

Contrived example:
Code:
#VAR ExtObject %comcreate("warrens.component")
#CALL %comset(ExtObject, "Text", "blah blah blah")
#VAR sometext %comget(ExtObject, "Text")
#SHOW sometext

All that works fine. If I do either
Code:
#UNVAR ExtObject
or
Code:
#VAR ExtObject ""

the COM object I'd created is no longer available for me to use, but Zmud doesn't release it, thus keeping the DLL in memory. Closing out the character doesn't work, either... I have to restart Zmud entirely.

Is there some way I can accomplish this? Or is Zmud just lacking the necessary functionality right now?

Thanks.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Aug 13, 2004 8:28 pm   
 
I've never used COM but I believe you need to use #COM or #CALL to execute the method which closes your COM object.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sat Jan 15, 2005 12:53 am   
 
I'm no expert at this but i believe that calling the COM object to close itself only does half the job.

Ive tested this using a system monitoring tool (TaskInfo2003 - Great Tool) and the following script.

#ALIAS RoomKind {#VARIABLE Conn %comcreate( "ADODB.Connection");temp=%concat( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", @LocalMapDatabase);#CALL @Conn.Open(@temp);#IF (@Conn.ConnectionString ="") {#SAY {%ansi( red)testing%ansi( white): Couldn't open connection to database.};#ABORT 1} {#ECHO open};#VARIABLE rs @Conn.Execute(%concat("SELECT k.name FROM KindTbl AS k, ObjectTbl AS o WHERE k.KindId = o.KindId AND o.ObjId =", %1,";"));#ECHO @rs.GetString;#CALL @rs.Close} "zMapperExtender"

This script simply creates an RoomKind alias, which takes as it's 1st parameter a room number, and returns the RoomKind name. Very handy to incorporate into zmud scripts.

As you can see, the alias calls the COM object to close itself with #CALL @rs.close, but this does not close the ADODB connection to the database.
Basically this means that everytime this alias is executed a new ADODB connection is created.

Does anyone know how to unload these ADODB connections once they are loaded?
(Note: I don't mean {#var Conn %null} as this simply unreferences the Connection)
_________________
That which does not kill us, makes us stronger.
Reply with quote
patryn
Apprentice


Joined: 26 Sep 2001
Posts: 124

PostPosted: Sat Jan 15, 2005 1:00 am   
 
#unvar Conn
Doesn't seem to work either.
_________________
That which does not kill us, makes us stronger.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jan 15, 2005 3:03 pm   
 
I believe that right now zMud simply does not have the facility to properly release these objects. Zugg stated somewhere that when it is time to update zMud again he will be improving the COM support with things he has learned in writing zApp. Until then scripts that make heavy usage of COM either have to reuse the objects or you will just have to periodically close and relaunch zMud.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Thu Jun 09, 2005 3:20 pm   
 
did this ever happen? i really could use a %comdestroy(), i have a perl script that i'd like to be able to edit/save then reload with the new settings. but apparenly from searching the forums i needa restart zmud each time?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jun 09, 2005 5:35 pm   
 
Actually, if using

#VAR ComObject ""

isn't release it, then that's a bug. I'll check into this. You don't need any special functions for destroying COM objects. Windows is *supposed* to handle the memory management of COM objects for you, so just clearing the variable is supposed to be good enough. It's equivelant to saying

ComObject = nothing

in VBScript. Now, it's possible that Windows is somehow caching the object internally. But in your ADO example, calling the @rs.close does *not* release any of the COM objects. It is creating a new connection each time you run it because you are calling %comcreate. Calling %comcreate forces Windows to create a new COM object no matter what you have done before. Anyway, try adding the

#VAR Conn ""

to your script, since you definitely need that.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net