Solved

Heap Usage In Delphi 5

Posted on 2000-03-30
10
265 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
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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