Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Memory leak in app, environment: W2k SP2, Delphi 6 (Pack 2), Oracle 8.1.7.4,DOA 3.4.6.1, OCI 8.1.7.2(4)

Posted on 2002-07-09
17
Medium Priority
?
538 Views
Last Modified: 2010-04-04
I have an application that processing tens of thousands of transactions daily. Application environment: Delphi 6(Pack 2), DOA 3.4.6.1, OCI 8.1.7.4, W2K SP2.
Each transaction is processed by a newly-spawned thread that creates a data module containing a Oracle session and multiple queries. Any given transaction will use 1-3 of the query objects. Sessions are not pooled.
It seem to be leaking several MB per day. I suspect it's related to the transaction volume. A desk check of my code appears clean - all GetMems balanced, no premature Exits, all object allocations seem to be freed.
0
Comment
Question by:YisraelE
  • 8
  • 8
17 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 7140329
Try minimizing and restoring your application. Does this bring back the lost memory?
0
 

Author Comment

by:YisraelE
ID: 7140373
Yes, the minimizing of main application form is lowereing the memory usage.

Yisrael.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7140377
Then try calling:

  SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1));

This should have the same effect. You shouldn't call it too often, though, since it costs performance. Perhaps call it once per day or something like that.

Regards, Madshi.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:YisraelE
ID: 7140443
My app is multy-trheaded. Is this workaround will make effect on all threads or I should to call this function from each thread context ?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7140492
Doesn't matter from which thread you call this function, since the working set size is specified per process, not per thread.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7140591
listening . . .
0
 

Author Comment

by:YisraelE
ID: 7140622
I have implemented your suggestion and I saw that the mem usaged was lowered, but the VM Size and Handles grows.
Currently the handles quantity is 1200 and VM Size is 22 MB.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7140636
You didn't talk about handles in your original question, just about memory usage.

The call to SetWorkingProcessSetSize just swaps out the RAM that is currently used by your process. After that call your process' memory usage slowly increases again. That's how it works. The big question is, if you call SetWorkingProcessSetSize once every day, is the memory usage after 2 weeks higher than after 1 week constantly running? If no, everything is fine. If yes, there must be a *real* leak.

If there is a steadily increasing amount of open handles, then something seems to be wrong. But handles have not much to do with memory usage. That are two different things...

Regards, Madshi.
0
 

Author Comment

by:YisraelE
ID: 7140653
Ok, I investigated this issue and saw that the Oracle client DLLs(my app uses these dlls) have memory leaks.
(I used a Memory Sleuth 2.0 for this).
Can you, please, help me to decrease a VM Size.

Thanks,
Yisrael.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7140661
How are you supposed to fix memory leaks in an Oracle client DLL? Do you have the source code?

I guess you will have to look for a new (bugfixed) version. Other than that I have no idea how to help you.

Well, you could automatically restart your process every day (let's say at midnight), but that would mean a few seconds delay.

Regards, Madshi.
0
 

Author Comment

by:YisraelE
ID: 7140677
Hello,Madshi.
Thank you for you answers. You helped me to decrease a Mem usage. Do you know about some API procedure that will decrease a VM Size of my app.

Thanks,
Yisrael.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 140 total points
ID: 7140688
Sorry, no idea. I'm not even sure what is meant with "VM Size". Where do you get the "VM Size" from?
0
 

Author Comment

by:YisraelE
ID: 7140744
The VM Size is a column from Windows Task Manager.
In my original message I refferenced to the following columns of Windows Task Manager: Mem Usage (physical memory size), VM Size (virtual memory size), handles (the number of opened handles).
I also investigated the handles count by using a tool Process Explorer that I downloaded from the site http://www.sysinternals.com/. This tools shows a number of opened handles by application,type of each handle and name of each handle.
I saw an enormous amount of handles of type Event and Semaphore which were opened by my app. I don't use semaphores in my app.I uses about 10-14 Critical Sections and a few mutexes to ensure my thread operations.
My app creates all critical sections and mutexes during initialization process and frees them during finalization process. I have no idia to decrease the number of handles and size of virtual memory.
I have also another strange effect in my app(My app is a server that has a TServerSocket to recieve requests from multiple clients via TCP/IP): I receive a following error from OS "Socket operation on non-socket (10038)" when the number of handles is too large( about 17,000). I checked my app with Memory Sleuth 2.0. It seems that my app has no memory leaks. Can you help me with the investigation of this strange problems: a large amount of handles, huge VM Size and non-socket operation.

Thanks,
Yisrael.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7140762
Ah, my task manager options didn't show those columns.

I think the VM size is the size of all the loaded modules. If I'm right with that guess, there's no way to reduce it. But it shouldn't increase over time then. Does it?

About the handles: There's a limit, I thought it would be gone in NT, but maybe it's not. In win9x the limit is exactly 16KB, which is 16 * 1024. That looks really like 17000. Maybe with sockets, this limit is still valid.

The question is: Who creates all those handles and why does he not release them?

You say you have a TServerSocket, I don't know too much about socket programming, but I guess every incoming request gets its own socket, or am I wrong? Do you release those sockets correctly?

Regards, Madshi.

P.S: Going home now, see you tomorrow...
0
 

Author Comment

by:YisraelE
ID: 7140778
Hello,Madshi.

You can see these columns in your Task manager by selecting the follwing TM menu: View/Select Columns ...
I'm using W2k SP2. May be you are using another Windows version ?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 7142615
I meant I originally had not turned those columns on. But I did turn them on before writing my previous comment.
0
 

Author Comment

by:YisraelE
ID: 7319721
The Oracle patch 8.1.7.4 fixes this memory leak.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question