Solved

Heap Usage In Delphi 5

Posted on 2000-03-30
10
262 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 93
TVirtualStringTree  search using TEdit 7 106
Downloading email attachments 2 67
URL for downloading Google Chrome for Win XP 2 122
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

16 Experts available now in Live!

Get 1:1 Help Now