Solved

Careful Memory Management

Posted on 2003-12-01
7
407 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
Comment Utility
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:
mnasman earned 125 total points
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Assisted Solution

by:j42
j42 earned 125 total points
Comment Utility
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
Comment Utility
BTW do not call yourForm.Destroy but use yourForm.Release
0
 
LVL 2

Expert Comment

by:-Karamja-
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now