Page 1 of 1

AhkThread and memory usage

Posted: 29 Nov 2021, 07:46
by murataygun
- I made a small script to log some stats to webdatabase.
- My main script runs this thread with some command arguments.

Code: Select all

AhkThread(postEvent, """Win + Q"" ""Test"" """" " SubStr(VERSION, -9) " " ISAKTIF " ""stat türü""")
(This logging activity will be used very often)

Everytime i use AhkThread my scripts memory usage increases about 1MB. One hour later it ends up hundreds of MBs.
My question is;
How can i manage this usage. Basicly i just want my small script/thread to [ Run - Do work - Die ] And left nothing behind. And may be a situation that this thread may run -allmost- concurrently. One after an other with different parameters.

Thank you.

Re: AhkThread and memory usage  Topic is solved

Posted: 29 Nov 2021, 12:19
by murataygun
I guess DynaRun instead of AhkThread did the jop.

Re: AhkThread and memory usage

Posted: 29 Nov 2021, 21:28
by HotKeyIt
You need to release/free the object used for the thread, see AhkThread.

Re: AhkThread and memory usage

Posted: 30 Nov 2021, 06:54
by murataygun
HotKeyIt wrote:
29 Nov 2021, 21:28
You need to release/free the object used for the thread, see AhkThread.
Yes. As i asked before; how am i gonna manage it? Thread works with newtwork. It may last 1 second or 20 seconds. How do i know when to terminate that thread. If i wait thread to finish its jop its nonsense to use Multi threading. Should i write my own garbage collection?

One more thing. Is my DynaRun implementation correct? Well it works but couldn't test really.

Re: AhkThread and memory usage

Posted: 30 Nov 2021, 21:47
by HotKeyIt
DynaRun should work fine, if you don't need to communicate to the threads.
I usually reuse my threads when they are not running anymore.