Solved

Careful Memory Management

Posted on 2003-12-01
7
411 Views
Last Modified: 2013-12-03
Hi, Hope this is the correct newsgroup.

I am trying to follow a Delphi /Win2k memory consumption problem by continuously viewing HeapStatus. For a reason that I'm trying to figure out, my TotalAddrSpace grows continuously, slowly, until the program crashes. Each time I show a form and close it, the TotalAddrSpace grows a by a megabyte or two, and returns to a number bigger than when I showed it. ALso, When I show a form, TotalAddrSpace and TOtalUncommitted grow.

FOr starters, if a form is
designed correctly with regard to memory allocation, should TotalAddrSpace
increase when a form shows and return to roughly the same number as before
it was shown when it is closed? Could someone explain exactly each of the many parts of Heapstatus, what they are for, which are allowed to grow or which should not grow...etc? Thanks.

Doug
0
Comment
Question by:dkeene
7 Comments
 
LVL 3

Expert Comment

by:JDuncan
ID: 9850325
The totaladdrspace should not grow just by showing and hiding a form. you must be allocating varables that take up memory inside your program which should be free'd up in the onclose event..

0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 125 total points
ID: 9850484
Hello

 Are you using auto create forms?, for auto create the forms and loading them in memory if so, remove them from auto create forms and  create the form dynamically at runtime, and when you close the form, use Form.Release method to remove it from memory

  also try to use some utilties to check the memory leaks in your application like

MemProof
http://www.automatedqa.com/downloads/memproof.asp

MemCheck
http://v.mahon.free.fr/pro/freeware/memcheck/

or more advanced but not free AQTime
http://www.automatedqa.com/products/aqtime.asp
0
 
LVL 2

Expert Comment

by:Robn
ID: 9850575
could you post your code of how you're creating and destroying these forms? Do the forms create objects or allocate memory when created?
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 2

Assisted Solution

by:j42
j42 earned 125 total points
ID: 9851036
Don' mix up
- Create: Get memory
- Show: Just show
- Hide / Close: Just hide
- Destroy: Release memory

If you want your memory released if you close the form add an Action := caFree; in the OnClose event.
0
 
LVL 2

Expert Comment

by:j42
ID: 9851040
BTW do not call yourForm.Destroy but use yourForm.Release
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 12381349
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Split: mnasman {611720} & j42 {1000229}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Karamja (Alan)
EE Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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