Amir Rant: "Memory Leak"

Apr 3, 2010
16,022
0
0
Seattle, WA
#1
Some problems are as old as dirt. One such thing in programming is called "memory leak."

Every computer program has two things: data and instructions on what to do with that data. When I type the letters "d" "a" "t" and "a." I am giving the browser that data. What it does with it is display the characters.

The data must be stored some place. And that place is the memory. It is the "DRAM" chips sitting in your computer some place.

Traditional programming calls for manually allocating chunk of memory inside the program, using it, and then "freeing" it so that it can be reused.

All is well as long as the programmer follows the sequence of, allocate, use and free correctly. But exceptions get in the way. An error condition occurs for the example and the program exits from that part of the code before freeing the memory. Keep repeating the same function and the memory allocated to the program starts to grow and grow. We call this a memory leak.

Memory leak like an air leak in your tires can be small or large. The latter causes you to have a flat, leading eventually to severe slow down and even hanging of your system.

Such was almost the case this morning. I wake up and while using my laptop I hear the alarm bells of something not being right: the fan in my laptop is running like mad even though all I am doing is typing on the Forum. The immediate diagnostic tool in Windows is called the Windows Task Manager which I invoke by holding the control key down, then pressing shift and escape keys all at the same time. Up pops this display which in this case, I have sorted by Memory column by pressing that heading:



We see a nice sorted display with Adobe Photoshop right on top, using 3.18 Gigabytes of memory at this instant. That is not all that much in this day and age. I usually have a few images open in it like the above display that I highlighted in Green. What was not right was watching that column grow and grow. Just a few seconds later, this is what the output looks like:



We are now up to 3.27 gigabytes in just a few seconds! And the meter kept running as was the fan. Not only was the memory being used but the app doing something to cause it even though I was not doing a thing inside Photoshop.

I went in there and closed the images I had open. There were about five of them. Once I did that, the memory growth stopped and with it, the fan in my laptop shut off. Oh, peace returns!

Looking at Task Manager, I see that it is using 3.25 Gigabytes of memory. So it gave a bit back but kept all of the memory it had gobbled up due that leak!

Fortunately, that is not a problem. The operating system will steal that memory back from it if it needs it. Since that memory will likely not be used by Photoshop anyway (since it had lost it due to leakage), it won't be an issue. But I can fix it if I want by quitting out of Photoshop and restarting it. Doing so now shows memory consumption of 0.27 gigabytes!

Memory leakage is one of those cardinal sins for programmers. If ever found there will be a black mark next to your name. You are supposed to write code that doesn't do this. And the test organization there to find them through proper testing. But here we are, with folks at Adobe given us such poor programming.

What caused the problem? It is hard to say but I have a clue. I was in Adobe Lightroom and told it I wanted to edit one of my images in Photoshop. It proceeded to save my file in uncompressed .tif format and hand it to Photoshop. I did my edit and closed that file and went into Lightroom. That was a couple of days ago. Fast forward to now and I am editing those to screenshots above which have .png extension. To my surprise, Photoshop wanted to save them as .tif by default! Clearly there is some lingering bug in the back and forth between Lightroom and Photoshop. Adobe makes both pieces of software but clearly didn't test the scenario well enough.

So next time your computer runs slow or you hear the fan running and warm air coming out, pop up the task manager. There is a similar app for MacOS by the way. Sort by CPU and Memory and see what is going on. You may be able to find and fix the offending program which in my case includes such apps as Microsoft Word or Outlook!!!
 

DonH50

Member Sponsor & WBF Technical Expert
Jun 23, 2010
3,518
1
36
Monument, CO
#2
Nice rant. I have been bitten my memory leaks numerous times over the years. At work, we have struggled with leaks in Java that crash long-term tests. They'll be there, get fixed in the next release, then re-appear in a later release. Have seen them in Windows and MS Office as well as third-party programs, and must admit having inadvertently created a few myself (perhaps one of the many ways to prove I am not a real programmer). Some compilers contribute to the problem, and dynamic memory allocation can contribute to it. It is insidious and not always at all obvious the root cause, either to the programmer or the end user whose computer crashes inexplicably.
 
Last edited:

Mosin

[Industry Expert]
Mar 11, 2012
894
0
0
#3
On my system, there are two such programs. One is Firefox, but it is to a manageable degree because the build up is over several hours. The ultimate culprit for me is that "sin against God" called Silverlight. It refuses to release memory once it uses it, and only a restart will clear it. As a result, Netflix is a "take an intermission every twenty minutes or forget it" scenario.
 

TBone

New Member
Nov 15, 2012
1,237
0
0
#4
>>Memory leakage is one of those cardinal sins for programmers. <<

Well, in the flat file days, not much of an issue, but when relational databases became the norm, much changed. Basic key field/indexed field type relationships are obvious, and simple enough, but many programmers felt the need to relate near any field to&from many tables. This caused massive memory issues, especially within a networked multi-user db.system, especially with locking and/or orphaned data. Well, a db that sorts your contacts/phone numbers, who cares, but in the financial world, it can become mission critical.

In one such case, a major financial corporation had apparently tried near every programmer/system analyst on premises and thru certain universities to fix a recurring billing issue. A random problem; every billing cycle, certain client's were incorrectly billed. The problem further compounded on every subsequent billing, messed up month-end processes / reconciliation. The databases were all designed by a very popular consulting company in NA, costing millions. They couldn't fix the problem, took no accountability, blamed other factors, and washed their hands. The db software company was based out of England, they had also been unsuccessful. At the time I was oblivious to all these issues, working with the same software within the Insurance Industry.

It was then that I was contacted, first by db software company, then by the Institution themselves. After getting clearance from both companies, I investigated ... the coding had been microscoped, filtered and refined by many prior. Hence, I also couldn't find anything wrong. The schema's seemed fine, the table structures fine ... but when I dug deeper into the non-key field related field definitions, although fine in theory, it became obvious that certain comprehensive loop-to-complete type codes/modules (case, do if, etc procedural commands) were possibly creating random situations in which a potential "memory leak" could result in data corruption, completely transparent to the end-user, and insidious in nature because you couldn't trace the millions of client records that may, or may not have been corrupted; the problem only become apparent upon client discovery.

Their resident computer experts/programmers near laughed me out the door.

Three weeks later, hired on contract, the problem fixed, they handed me Y2K compliance and all it's associated "cardinal sins" ...
 
#5
JRiver 18 seems to have a memory leak too. If I leave it running for many days, which is normal, ultimately it sucks up all the available memory and becomes unresponsive. Maybe later versions are improved, but those damn leaks, ugh!
 
Apr 3, 2010
16,022
0
0
Seattle, WA
#6
That's ugly. It reminds of a service in Windows (audiodg.exe) that also has a massive memory leak and eventually kills my machine. Foobar2000 hits it in my case any time I do an ABX test with it. I forget sometimes and days later wonder why my machine comes to a near halt. Microsoft has a hotfix but it does not install.
 

DonH50

Member Sponsor & WBF Technical Expert
Jun 23, 2010
3,518
1
36
Monument, CO
#7
I have been testing a new device and some of the tests take a week-plus to run. One piece of test equipment kept crashing after running a few days to a week or so, then would crash more frequently. This was quite vexing, especially in a quarter-million dollar (USD) piece of test equipment, and cost me a couple of weekends. After running me through the usual hoops (check your test script, must be your device, update the OS/SW/FW/etc.) they discovered their interface SW had a memory leak. Sigh...
 
Apr 3, 2010
16,022
0
0
Seattle, WA
#8
Sadly it is remarkably common still. If I run the Foobar ABX plug-in, it causes the main audio pipeline in Windows (audiodg.dll) to develop a memory leak. Even if you exist from foobar, the leak continues until it eats all of system memory and performance comes to a halt! Sadly Microsoft only put out a hotfix that does not work/install on my Windows 7 machine and I have to reboot to fix it :(.
 

Folsom

VIP/Donor
Oct 26, 2015
2,553
0
36
Eastern WA
#9
Websites with lazy as **** coding... Car manufacturer website are pretty bad, often. FireFox will run fine for me, then I start visiting all sorts of non-forum based stuff and it chokes like hamster eating a poodle. It's nonsense, just lazy idiots that should be canned but somehow keep building websites.
 
#10
Am I reading this thread? Because if I was, Internet Explorer is eating more CPU and memory than anything else right now. My fan is blowing, but not excessively.
Excessive would be like a rain forest from the Amazonian jungle trying to overwhelm me with constant rain falling down on my head and shoulders.
 
Last edited:
Apr 3, 2010
16,022
0
0
Seattle, WA
#11
Websites with lazy as **** coding... Car manufacturer website are pretty bad, often. FireFox will run fine for me, then I start visiting all sorts of non-forum based stuff and it chokes like hamster eating a poodle. It's nonsense, just lazy idiots that should be canned but somehow keep building websites.
Indeed. What gets me is so many scripts running so many animated ads that the machine cooks and cooks good. On my last laptop I could not visit AVS forum. The bottom would get so hot as to burn my lap! Talk about wasting power. It literally pushed me towards installing an ad blocker and then the situation became manageable.

Mind you, I think they should do what they need to make money. But they should test to see if their site is sucking an entire core i5 processor just sitting there without me doing anything!
 
May 19, 2014
693
0
16
Round Rock, TX
#12
Amir, looks like you also have a problem with Chrome. You shouldn't have that many processes open burning that much memory. That may be another problem on your PC..
 
#13
Amir, you are a Microsoft expert. You already know that animated commercials from places like Facebook and Twitter can slow down your PC.
Multitasking, downloading hi res music, Skype, Vudu, Netflix, burning copies of UHD movies, etc., they can all slow down your navigation. ...Apps running in the background, ...high resolution pictures, ...

The Task Manager indicates what's going on. ...If someone tries to access your browser, your mouse, your coordinates, your actions, your privacy, ...you are the expert who knows all of that. ...Your Internet service provider, the speed they provide you with, how many more PCs connected to your main modem/router center, all the activities from the Internet, etc., and from all your family. Me I don't know, I'm just shooting ideas. When I have issues you are one of the top people I would ask for the solution, and among few other PC member experts here...the ones still active, or reading.

I realize that this thread is older, but it has been resurrected and the subject is very real in today's world we live in. Windows 10 wants to be in everywhere.
The Apple people are reading this and they probably say to themselves: How come I don't experience those kind of issues, but different ones?

Scott and Vincent are the two local PC experts; that's their job of expertise to help people like me, and you. :b
I'm sure there are others too...

P.S. AVSForum has over one million members, and advertising (animated) is one of their main source of revenues.
Naturally normal to be a slower site overall as compared to most smaller sites with less animated commercials and google checking on you, etc.
There are so many functions and features inside our ordinateurs that it's not always organized efficiently. Internet Explorer says it...explorer.
 
#14
Add icloud sevices to the offender list. Yesterday my machine was having trouble drawing windows without big black blank spaces. I knew where to look, opened task manager, and icloud services was gobbling over a gig of memory. On reboot it was tamed to about 4 mb. Granted, I regularly have a dozen apps open, including memory hogs like Photoshop, InDesign, and Outlook (fat pig), and sometimes don't reboot for weeks at a time—making leaks even more apparent.

(And no, I did not think icloud services was related to drawing of the screen, but the problem is a sign of memory issues.)
 
Apr 3, 2010
16,022
0
0
Seattle, WA
#15
Amir, looks like you also have a problem with Chrome. You shouldn't have that many processes open burning that much memory. That may be another problem on your PC..
At any one time, I probably have 30 to 40 tabs open in a dozen browser session :). So no, there is not a problem there. It is the way I work. :) :)