Solved

Careful Memory Management

Posted on 2003-12-01
7
410 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JAudiorecorder record freezing the app 29 67
Delphi...Split view - idea? 1 68
how to resize animated Gif image in delphi ? 1 31
enhance the following code 3 32
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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