Solved

Careful Memory Management

Posted on 2003-12-01
7
413 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
Technology Partners: 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!

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Title # Comments Views Activity
Base1 Encode/Decode 3 90
Dynamically Created Query 3 70
How are Button Fonts Created? 2 44
TlistView is Really heavy on Android 3 22
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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…

730 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