Solved

Heap Usage In Delphi 5

Posted on 2000-03-30
10
277 Views
Last Modified: 2010-04-04
We need to convert a large Pascal system to Delphi 5.  It uses heap structures with thousands of entries extensively that it creates on the fly and then releases.  What is the most elegant way to do this in Delphi 5.  Do we need to release each instance of each New or come up with some more global approach?  

Is there a way to mark and release like the original Turbo Pascal?  Do people often create operations like mark and release or do they individually get rid of each instance created by new?  The numbers of entries in the system being addressed make this seem unelegant.

What is meant by doing our own caching?  What do we do to create these caches?  We think we can prevent events from writing into marked memory by not using these types of structures for anyone but the heap writing/reading process.  Are we wrong?
0
Comment
Question by:micrdick033000
[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
10 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2671195
Possibilities are:

- AllocMem and FreeMem
- New and Dispose
0
 

Author Comment

by:micrdick033000
ID: 2673012
Edited text of question.
0
 
LVL 4

Expert Comment

by:Radler
ID: 2673102
Hi friend,

I remember that at past you give more points( I'm rigth ? )
Are you tried the another compiler to make a DLL with your framework ?
Take a look at
http://tfdec1.fys.kuleuven.ac.be/~michael/fpc/download.html
Good luck.
T++, Radler.
0
Industry Leaders: 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 10

Expert Comment

by:Lischke
ID: 2676439
Actually, Mark and Release are very unreliable functions in event driven environments. You can never be sure that not some class or similar has been created since your last call to Mark triggered by some incoming event about which you are not informed. Actually, the heap management of Delphi is meanwhile so sophisticated, you don't need to care about allocating many records and releasing them as long as you are doing this not too often (otherwise you will bring down *every* system). If you need to allocate and free many memory pieces then do your own caching.

Ciao, Mike
0
 

Author Comment

by:micrdick033000
ID: 2682265
It seems use of the heap as we were donig it is not used often in Delphi Object Pascal, and the commentors don't have any experience with our problem.  We plan to experiment and determine the best course.
0
 

Author Comment

by:micrdick033000
ID: 2682266
This question has a deletion request Pending
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2683088
This question no longer is pending deletion
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2683089
I disagree. Firstly, I have indeed much experiences in the field you described (allocating large amount of records and releasing them as well as all kind of fast sorting, accessing, management etc. etc.) and secondly, your question was:

--------------
Is there a way to mark and release like the original Turbo Pascal?  Do people often create operations like mark and release or do they individually get rid of each instance created by new?  
--------------

for which you got answers! It seems to be common bad habit to consider negative answers as being no answers.

I'm not willing to accept this.

Ciao, Mike
0
 

Author Comment

by:micrdick033000
ID: 2683125
Edited text of question.
0
 
LVL 10

Accepted Solution

by:
Lischke earned 50 total points
ID: 2683173
I don't know why you don't ask directly what you want but from your reworded (well, extended) topic question I think I get what you are after.

Actually, creating the cache I mentioned is trivial. The keypoint there is to manage that part of the memory your self which is related to your many data records to separate it from those memory created for classes, other records etc. So what you could do is to allocate a large block from Delphi's heap manager and always "allocate" your small record blocks from this large block. "Mark" would then correspond to allocating the large block and "Release" to free it entirly. The most difficult thing I can imaging is the free blocks management if the amount of allocated sub blocks varies often. If you just allocate, say, one million records, work with them and deallocate them, then it garbage collection is not a matter you need to consider. Otherwise look into the VCL source code how the VCL does the managment.

Ciao, Mike
0

Featured Post

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!

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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