Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8686035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:44:05+00:00 2026-06-12T22:44:05+00:00

I am using a TObjectList (Delphi 2007) to store A LOT of data- I

  • 0

I am using a TObjectList (Delphi 2007) to store A LOT of data- I expect to have around 300 thousand elements or even more. However, when a list is created, it’s default size is set to store only four elements, then eight if one tries to add a fifth element, then sixteen if one tries to add a ninth element and so forth. The numbers may be off, but I think the workings are correct. The problem with this is that all the elements have to be copied from the deallocated part of the memory to the new memory block where the new extended list migrates. I would like to set a specific initial size and deallocate (or undo the reservation of memory, since reserving and allocating aren’t the same thing) any unused space that the list has allocated/reserved.
This probably isn’t a lot of code, but I think that there should be a permanent, solid reference to this problem in the form of a question and answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:44:06+00:00Added an answer on June 12, 2026 at 10:44 pm

    Set the Capacity to the highest number of elements you expect, fill the list, and then set the Capacity to what you actually used (optional). This avoids all of the allocate/move/allocate/move stuff.

    MyList.Capacity := 300000;
    // Add 280000 items here
    
    // Optionally, reduce the capacity. It's not important to do so unless
    //  you end up with a lot of unused items.
    MyList.Capacity := MyList.Count;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have quite a lot of data to store, read and modify in memory
I have make some functions to retrieve data using the Github API. I have
I have a generics class, that uses TBase as the type parameter. Using MEF,
Using RestKit 0.10.1, I have objects served similar to this json format: {objects: [
using Telerik.WinControls.Data; using Telerik.WinControls.UI.Export; namespace Directory { public partial class radForm : Form {
I have defined a UI (let's call it myUI) using the Qt designer, and
I have a class that contains two arraylists which I'm trying to store objects
Using Android TelephonyManager an application can obtain the state of data activity over the
Using MVC2 I have an AJAX form which is posting to a bound model.
Iam using borland 2006 c++ class A { private: TObjectList* list; int myid; public:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.