Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

New to the world of Memory Leaks


  • Please log in to reply
7 replies to this topic
Costas
  • Members
  • 174 posts
  • Last active: Jul 21 2016 02:28 AM
  • Joined: 31 Mar 2009
Dear Fellow AutoHotKeyers,

Greetings!

In a prior life, on another planet .... errrrrr... I mean platform, we never even had the phase "Memory Leak".

Now I find myself in the Microsoft realm and have had my first nasty encounter with memory leaks and someone
not cleaning up their garbage.

Recently I installed some new EDI software. Once in a while, it would fail upon initiation. When I called the vendor and told them about the error that I was receiving, they told me to simply re-boot
to fix the problem. It did so and the re-boot did indeed fix the problem. The vendor also said that the error that I was seeing was the result of other programs not freeing up memory when they close.

Here is the software that is used on this PC. Word, Excel, Access, Outlook Autohotkey, and the new EDI software.

Again, I am new to the problem of memory leaks. I am not sure where to start looking.

Dumb question - I know that AHK can do some pretty cool stuff. Is it possible to use AHK to look at a PC's
memory and determine if another program is now playing nicely?

Is it possible to have a memory leak in AHK? If so, how can this be avoided?

Thanks,
Costas

Planet Tralfamadore

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
I suppose it's possible that AutoHotkey has a memory leak somewhere but i haven't noticed one. I'm dealing right now with an AutoHotkey app that has over 1700 lines of code spread out over 4 files and i havent seen any indications of unreachable memory. Generally every software developer points to the other guy when memory leaks show up. Microsoft software was infamous for it. especially MS Office. That's another reason besides price, why i use OpenOffice instead. I don't know about the EDI stuff. I would recommend you use task manager or process explorer to see what processes are using what memory and try to figure out what's going on.
the latest process explorer is nice (and free) and you can download it from http://technet.micro...ernals/bb896653
I use it a lot when i need to check on what my system is doing or dump non-critical apps to free up memory space.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
In task manager go to the Processes tab. There should be a memory column. If it keeps rising for one process... that's your leak.

You may have to customize the columns to get anything useful.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

Costas
  • Members
  • 174 posts
  • Last active: Jul 21 2016 02:28 AM
  • Joined: 31 Mar 2009
GirlGamer and Frankie,

Thanks for the help, I appreciate it.

This is probably a really dumb question and I am not sure even how to phrase it.

Are all chunks of memory that are not "freed up" tied to processes that I can see in the Task Manager?

In other words, is memory only tied up if there is a process that is somehow holding it?

I have heard the term garbage collection. Is this then simply killing off tasks? For some odd reason, I had this idea that memory can somehow be not freed up even it is not tied to a process that is running.

Thanks,
Costas

Frankie
  • Members
  • 2930 posts
  • Last active: Feb 05 2015 02:49 PM
  • Joined: 02 Nov 2008
Garbage collection, to the best of my knowledge, is when a programing language cleans up memory that it no longer needs.

How does the OS deal with memory internally? Not a clue.

You can do some Google/wikipedia searches if you're still curious.
aboutscriptappsscripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
some older processes can exit operation and leave behind what's called "orphaned" memory blocks that never get freed up. This is the very definition of a memory "leak". Since these blocks belong to no process at all there may be no way to free the memory or return it to the available memory pool. This is a common problem with programmer managed memory languages like C/C++ and some others. The term "garbage collection" was coined as a tag for a process that attempts to recover this orphaned memory. The only absolutely sure way to regain access to all available memory however still requires a complete machine hard reboot. This essentially requires shutting off the machine and restarting it from scratch. Sometimes even a soft reboot won't return all of it.

When memory is tied to a running program or process that memory is normally visible in the process explorer window. Processes mainly are required to clean up their own memory allocations when they no longer need them. The operating system generally has a memory manager that can handle that and the process simply needs to call the API for that to free the memory and flag it as available for use. Over time memory blocks can, just like hard drive blocks, become fragmented and "chunked" over the entire memory space. This is another function of garbage collection as well -- gathering up all the loose change of memory and trying to construct a solid block of memory for other programs to use. To do that oft-times the garbage collector will have to suspend running programs and processes and reallocate their memory blocks sort of like a hard disk defragmenter. To the extent that the garbage is spread out through the entire memory space, the machine may slow down, lag, and even seem to freeze up for periods of time while garbage collection is in progress. This is particularly noticeable in older (pre multi core) machines.

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


Costas
  • Members
  • 174 posts
  • Last active: Jul 21 2016 02:28 AM
  • Joined: 31 Mar 2009
GirlGamer,

Thanks for the nice explanation of memory management, I appreciate it.

Of the applications that run on the PC with the occasional problems, I would guess that Access is the culprit rather than Word, Outlook, or Excel.

I say this because the Access applications have custom built VBA code.

Thanks again,
Costas

PS. I sometimes long for Planet Tralfamadore where memory management was of no concern for application developers.

girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
One never truly begins to know the dark corners of a personal computer, or needs to shine a light in there, until they begin to use Microsoft software.
(Parody) Heard eminating from Bill Gates' office, "Verily, I shall make The World my alpha site and it will rejoice."

The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif