?
Solved

Careful Memory Management

Posted on 2003-12-01
7
Medium Priority
?
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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 500 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

764 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