Solved

Heap Usage In Delphi 5

Posted on 2000-03-30
10
259 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

11 Experts available now in Live!

Get 1:1 Help Now