AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM Standard Library
Goto page Previous  1, 2, 3 ... 7, 8, 9, 10, 11, 12  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 1331

PostPosted: Mon Jun 30, 2008 5:13 am    Post subject: Reply with quote

Joy2DWorld wrote:
actually, whole idea of ez_invoke was to cache the middle objects so would be *fast* and avoid unnecessary recreation.

That's surely a clever idea, however, I'm not sure if it's a good idea. If never call ez_reinvoke(), then the number of the middle objects left unreleased can be monotonically growing while the user is unaware of. It may not matter with short-lived scripts, but can leak noticeable resources with a resident script.

In one thought, I got the feeling that it may be better to leave the worries of performance to SCM/COM manager and/or to (author of) the COM object. Have you tested the performance difference between caching and non-caching? Anyway, just a thought.

BTW, I used to use it something like
Code:
CreateObject("Shell.Application").Windows.Item(0).LocationName
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2544
Location: Australia, Qld

PostPosted: Mon Jun 30, 2008 9:41 am    Post subject: Reply with quote

tank wrote:
somehow i guess i was under the impression that if i never created an ahk variable i dont need to release it
By retrieving a pointer to an object (via property or method call) you are incrementing the reference counter of the object. From AutoHotkey's perspective, the pointer is simply a string of numerical digits, so it does not matter whether you store the pointer in a variable. If you don't release the "reference" (via COM_Release(pointer)) the reference counter will never reach zero, and the object will likely remain in memory until the program exits.
Quote:
and it wont hurt anything i think your saying there is a potential prablem here
It will- how much depends on what resources are associated with the object (memory, processes, network connections, images, etc.)
Joy2DWorld wrote:
hey, 1. Com_InvokeDeep is not in same animal group as ez_invoke().
Now that I think of it, ez_Invoke was a bad example to use (in the context of my post), since it doesn't automatically release the intermediate (or middle as Sean called it) object.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 617

PostPosted: Mon Jun 30, 2008 1:19 pm    Post subject: Reply with quote

Lexikos wrote:
tank wrote:
somehow i guess i was under the impression that if i never created an ahk variable i dont need to release it
By retrieving a pointer to an object (via property or method call) you are incrementing the reference counter of the object. From AutoHotkey's perspective, the pointer is simply a string of numerical digits, so it does not matter whether you store the pointer in a variable. If you don't release the "reference" (via COM_Release(pointer)) the reference counter will never reach zero, and the object will likely remain in memory until the program exits.
.

Out of sheer curiousity what happens to those references on COM_Term()
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Mon Jun 30, 2008 2:52 pm    Post subject: Reply with quote

Sean wrote:
Joy2DWorld wrote:
actually, whole idea of ez_invoke was to cache the middle objects so would be *fast* and avoid unnecessary recreation.

That's surely a clever idea, however, I'm not sure if it's a good idea. If never call ez_reinvoke(), then the number of the middle objects left unreleased can be monotonically growing while the user is unaware of. It may not matter with short-lived scripts, but can leak noticeable resources with a resident script.


any cleverness purely inspired by your Invoke...

note:
Code:
ez_revoke(object_string,1, 2)


releases entire string of objects.

ez_revoke(object,start after object #, [1 = actually release 1st object only ; 2 = actually release EACH object in string; 0 = just revoke and not release])


Quote:
Have you tested the performance difference between caching and non-caching? Anyway, just a thought.


yes. releases are HUGE DRAG to exec. time.

have played with new thread to release, but unsure of hidden consequences of such approach.

Code:
Release_T(ppv) {
   global
   static iran
   ppvG := ppv
   if !iran {   
      Release_CBA := Com_RegisterCallback("Release_CBF","Fast")
      iran  = 1
      hThreadId = XX
   }
   
   if !ppv
      return
      
   hThread  := DllCall( "CreateThread", UInt,0, UInt,0, UInt,Release_CBA 
      , UInt,0, UInt,0, UIntP,hThreadId )    
   sleep -1   
}

Release_CBF( ) {
   global ppvG
   DllCall(NumGet(NumGet(1*ppvG)+8), "Uint", ppvG
   ppvG = 0
}

_________________
Joyce Jamce
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1331

PostPosted: Mon Jun 30, 2008 4:50 pm    Post subject: Reply with quote

Joy2DWorld wrote:
note:
Code:
ez_revoke(object_string,1, 2)
Actually I had read that. What I wasn't sure was that it only releases the objects, or does after evaluating/executing the expression.
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Mon Jun 30, 2008 5:49 pm    Post subject: Reply with quote

Sean wrote:
Joy2DWorld wrote:
note:
Code:
ez_revoke(object_string,1, 2)
Actually I had read that. What I wasn't sure was that it only releases the objects, or does after evaluating/executing the expression.


ez_revoke() just clears the cache [and releases based on global setting or option].

ez_reinvoke@() clears cache [and releases based on global setting] AND re-invokes.


ps: originally was just clearing cache, until Lexikos pointed out the potential folly of leaving thousands of open COM objects laying around with no pointers to release them.....
_________________
Joyce Jamce


Last edited by Joy2DWorld on Tue Jul 01, 2008 2:38 am; edited 1 time in total
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 617

PostPosted: Mon Jun 30, 2008 11:29 pm    Post subject: Reply with quote

Sean wrote:


COM_Error() function.
It'll control the notice of error(s) happened inside COM_Invoke(), which is default to On. COM_Error()/COM_Error(False) to turn it off, and COM_Error(True) to turn it on again.
It filters out severe failure which result in the empty returned value as I felt it could be too intrusive, however, if there is a need of including it please let me know.

fantastic by the way this just shortened debugging my javascript a bit in a round about way
i have several thousand lines of ahk and javascript being inserted and executed(several scripts)
this immediately halts the script and then i view variables and contents to see where the script is at i go straght to the peice of javascript and fix the problem
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1331

PostPosted: Tue Jul 01, 2008 1:17 am    Post subject: Reply with quote

tank wrote:
fantastic by the way this just shortened debugging my javascript a bit in a round about way

Glad you like it. Smile Now it's mysterious to me why I hadn't thought about it before.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2544
Location: Australia, Qld

PostPosted: Wed Jul 02, 2008 6:37 am    Post subject: Reply with quote

tank wrote:
Out of sheer curiousity what happens to those references on COM_Term()
My educated guess-
The COM libraries are freed, and maybe the libraries implementing the objects. The object references (and resources they refer) may or may not be released, depending on their implementation.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1331

PostPosted: Wed Jul 02, 2008 7:13 am    Post subject: Reply with quote

Lexikos wrote:
tank wrote:
Out of sheer curiousity what happens to those references on COM_Term()
My educated guess-
The COM libraries are freed, and maybe the libraries implementing the objects. The object references (and resources they refer) may or may not be released, depending on their implementation.

When the reference count of COM Library (i.e. through CoUninitialize or alike) reaches zero, all dlls containing the (in-process) COM objects loaded by SCM/COM will also be freed AFAIK. So, no need to concern about them, and I suppose this is why it's discouraged to call directly DllGetClassObject. However there may still remain problems with out-of-process COM objects. So, better always call Quit or similar methods whenever they are no longer needed in case of out-of-process COM objects.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 617

PostPosted: Wed Jul 02, 2008 12:40 pm    Post subject: Reply with quote

dumb question from an idiot
how would one "Quit" as o0pposed to COM_CoUninitialize()
to deal with out of process objects
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1331

PostPosted: Wed Jul 02, 2008 2:07 pm    Post subject: Reply with quote

tank wrote:
how would one "Quit" as o0pposed to COM_CoUninitialize()
Quit is not opposed to CoUninitialize, it's analogous to ExitApp of AHK. Most out-of-process COM objects, i.e. local servers, support the method Quit, at least those from MS like InternetExplorer.Application, Excel.Application, Word.Application etc. So the safest routine would look like
Code:
COM_Init()
pie := COM_CreateObject("InternetExplorer.Application")
...
COM_Invoke(pie, "Quit")
COM_Release(pie)
COM_Term()
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 617

PostPosted: Wed Jul 02, 2008 6:33 pm    Post subject: Reply with quote

ok to the quit kills all the objects left out there in la la land created from it
thanbks for the clarification
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 617

PostPosted: Sat Jul 05, 2008 10:44 pm    Post subject: Reply with quote

sean or Lexikos

take any invoke call you like one works flawlessly on one pc well most actually windows xp professional sp2 but doesnt work at all on another computer

these are on a corp domain without roaming profiles but the registry and policies move with user

if a different user logs in on the pc where the script does not work for that other user the script works

given this description i pretty much rule out sysntax (tell me if im wrong)


I have also ruled out a bunk ahk install (again if im wrong to do so then tell me)

what other troubleshooting steps might i try in an effort to narrow down the cause

computer 1-24 all fine
computer 25 user 25 nothing happens no result returned
computer 25 user 24 every thing works ?????
ahk com functions seem to be the only anomoly at this time
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Sun Jul 06, 2008 12:31 am    Post subject: Reply with quote

any setting differences w/ the odd machine,

for example: priv. differences, security settings, etc.

a anti-virus prog, etc.


ps: have you test ahk messaging, callbacks generally ?
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 7, 8, 9, 10, 11, 12  Next
Page 8 of 12

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group