 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sean
Joined: 12 Feb 2007 Posts: 1331
|
Posted: Mon Jun 30, 2008 5:13 am Post subject: |
|
|
| 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 |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2544 Location: Australia, Qld
|
Posted: Mon Jun 30, 2008 9:41 am Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 617
|
Posted: Mon Jun 30, 2008 1:19 pm Post subject: |
|
|
| 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 |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 422 Location: Galil, Israel
|
Posted: Mon Jun 30, 2008 2:52 pm Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1331
|
Posted: Mon Jun 30, 2008 4:50 pm Post subject: |
|
|
| 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 |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 422 Location: Galil, Israel
|
Posted: Mon Jun 30, 2008 5:49 pm Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 617
|
Posted: Mon Jun 30, 2008 11:29 pm Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1331
|
Posted: Tue Jul 01, 2008 1:17 am Post subject: |
|
|
| tank wrote: | | fantastic by the way this just shortened debugging my javascript a bit in a round about way |
Glad you like it. Now it's mysterious to me why I hadn't thought about it before. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2544 Location: Australia, Qld
|
Posted: Wed Jul 02, 2008 6:37 am Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1331
|
Posted: Wed Jul 02, 2008 7:13 am Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 617
|
Posted: Wed Jul 02, 2008 12:40 pm Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1331
|
Posted: Wed Jul 02, 2008 2:07 pm Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 617
|
Posted: Wed Jul 02, 2008 6:33 pm Post subject: |
|
|
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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 617
|
Posted: Sat Jul 05, 2008 10:44 pm Post subject: |
|
|
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 |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 422 Location: Galil, Israel
|
Posted: Sun Jul 06, 2008 12:31 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|