General Macro Scheduler discussion
Moderators: Dorian (MJT support), JRL
- Junior Coder
- Posts: 22
- Joined: Thu Sep 17, 2015 6:06 pm
So in the MS Manual it says:
Libraries loaded with LibLoad should always be freed with a call to LibFree after being used.
I have a program that does a LibLoad>user32.... at the beginning of the program and then LibFunc>user32,FindWindowA.... several times within the program.
My question is should I be using the LibLoad and LibFree commands at the beginning and end of every LibFunc instance, or can I do one LibLoad at the very beginning and one LibFree at the very end?
What are the potential consequences of using a LibLoad without a LibFree?
- Automation Wizard
- Posts: 3230
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
My experience has been that the standard Microsoft libraries such as User32.dll are always preloaded by the operating system and do not need to be loaded using LibLoad>. LibLoad> is really meant for third party libraries.
But, to answer the question, in a particular script id LibLoad> is used to load a specific dll file it only needs to be loaded once and only needs to be freed once.
The consequence if failing to free the library function is a small bit of memory consumed. It will be restored on your next computer reboot.
- Site Admin
- Posts: 7029
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
If you are doing lots of LibFunc calls on the same DLL then, yes, in theory, using one LibLoad at the start and one LibFree at the end might be marginally faster, since the DLL would not need to be loaded for every call. Whether you notice any difference or not is questionable.