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
Solved

Heap Usage In Delphi 5

Posted on 2000-03-30
10
270 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 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