469,325 Members | 1,578 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

Strange MemoryLeak Issue

Airslash
221 100+
Hello,

I hope this falls under the correct topic...

We have a small application that uses the COM ports on a system to communicate with external devices. This application is written in Delphi and makes use of some third-party components.

We have around 500 identical systems, sort of speak, and there's only one location where this application is getting memoryleaks up to 500mb.
All other locations are running fine and don't suffer from this problem.

I'm more inclined to believe this to be a Windows problem on that system then a fault in the application. Anyone who can shed some insight on this, or experienced a similar issue?
Jul 29 '10 #1
15 1343
Jyoti Ballabh
115 100+
In most Delphi applications, where you use the components you drop on a form, you do not need to care to much about memory management. Once the component is placed on a form, the form becomes its owner and will free the memory taken by the component once the form is closed. Form, as the owner, is responsible for memory deallocation of the components it hosted. In short: components on a form are created and destroyed automatically. Now, when you need to use the TDeveloper class, you create an instance of the class by calling the Create method (constructor). The Create method allocates memory for a new object and returns a reference to the object.

var
zarko : TDeveloper
begin
zarko := TMyObject.Create;
zarko.DoProgram;
end;

This is a simple memory leak
Jul 29 '10 #2
Jyoti Ballabh
115 100+
Whenever you create an object, you must dispose the memory it occupied. To free the memory an object allocated, you must call the Free method. To be perfectly sure, you should also use the try / finally block:

var
zarko : TDeveloper
begin
zarko := TMyObject.Create;
try
zarko.DoProgram;
finally
zarko.Free;
end;
end;

This is an example of a safe memory allocation and deallocation code.

Warning: If you want to dynamically instantiate a Delphi component and explicitly free it sometime later, always pass nil as the owner. Failure to do so can introduce unnecessary risk, as well as performance and code maintenance problems.
Jul 29 '10 #3
Airslash
221 100+
I know what might cause a memory leak in Delphi.
I'm more interested as to why the memory leak only occurs on one specific system and not the 245 other systems we have running.

And they're all running the same OS, have the same hardware and run the same version of the software written.
Jul 29 '10 #4
Jyoti Ballabh
115 100+
I'll get back to you later on this one. An isolated instance of system memory leak. I can think of either malware of defect in Assembly Coding. I have never encountered or tackled this problem before.
Jul 29 '10 #5
Airslash
221 100+
aye,

it's a first one for me as well.
Normally if it's a coding memoryleak I expect it to appear in all the applications on all the systems, but it's really just this one.
Jul 29 '10 #6
Jyoti Ballabh
115 100+
that's what got me thinking, if it's a coding error or let's say something to do with the OS, the problem should persist in all the systems; why just one? I will have to rule out any mechanical damage or should I?
Jul 29 '10 #7
Airslash
221 100+
I doubt mechanical damage to the components would be the cause. I'd expect the application or even the system to simply crash if the memory got damaged.

Any suggestions on a good diagnostics tool to check RAM and system performance?
Jul 29 '10 #8
Jyoti Ballabh
115 100+
I don't know, I do it the old fashioned way if I have to. Run through the Windows memory diagnostic executable file, mtinst.exe...... i can give you the details on this one if you want.
Jul 29 '10 #9
Jyoti Ballabh
115 100+
For some hardware configurations, Windows Memory Diagnostic can identify the specific failing memory component. If Windows Memory Diagnostic can successfully isolate all the errors detected to one or more corresponding memory modules, the View errors by memory module option will be available in the menu. You can use this option to determine which specific memory modules are failing and need to be removed or replaced. This could be one of the causes of the memory leaks. I am not entirely sure, though.
Jul 29 '10 #10
Airslash
221 100+
I'll take a look at it.
Jul 29 '10 #11
Oralloy
983 Expert 512MB
Just as an observation, the easiest fix might be to re-build the failing system.

Either re-install your stock image (assuming you have one), or start with a Windoze disk and re-install all the necessary software.
Jul 29 '10 #12
Airslash
221 100+
not an option i'm afraid.
This is a live production system at the client and cannot be simply taken down.
Jul 29 '10 #13
Oralloy
983 Expert 512MB
Unfortunate. It's probably cost everyone more time to "fix" the problem at this point than a rebuild will take.

Sorry, I've been caught where you are, too. There are no pretty answers.

Please let us know what the resolution is, when you find it.

Good Luck!
Jul 29 '10 #14
Airslash
221 100+
will definitly keep you updated on our "adventure".

Tommorow we're spitting through all the log files we have been generating from perfmon and see if we can find anything.
Jul 29 '10 #15
Jyoti Ballabh
115 100+
yea, I am pretty sure that the only reason why this is happening is due to the run time error in one of the executable files. Run the WDEF for the system and see what sort of message do you get.
Jul 30 '10 #16

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by J P Singh | last post: by
9 posts views Thread by Robert Misiorowski | last post: by
reply views Thread by WC Justice | last post: by
25 posts views Thread by Neil Ginsberg | last post: by
2 posts views Thread by Tariq Ahmad | last post: by
1 post views Thread by Torfi | last post: by
4 posts views Thread by Mr.SpOOn | last post: by
3 posts views Thread by ziycon | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.