What is the array of objects memory
Arrays and storage
An array, unlike data that you store in tables and records on disk, is always kept entirely in memory.
For example, if you enter all postcodes in a table [Postcode], it will contain around 10,000 data records. The table naturally contains other data fields such as country code and city. If you now select postcode area 8, the 4D database engine creates the corresponding data record selection in the [Postcode] table and loads the data records only when required, e.g. for display on the screen or for printing. In other words, you are working with an ordered series of values of the same type that the engine loads partially from disk into memory.
This approach is unthinkable for arrays. This has the following reasons:
- To manage the three pieces of information, country code, zip code, and city, you would need to keep three large arrays in memory.
- Since an array is always kept entirely in memory, you would have to keep all of the information from these arrays in memory for the entire working session, even if you don't need the data all the time.
- Each time the database is started or stopped, these arrays would have to be completely loaded and then saved on the hard disk, even if the data was neither used nor changed during the entire work session.
Conclusion: In arrays, manageable amounts of data should be kept for a short period of time. Because arrays are held in main memory, array operations are very fast. You can copy, sort, search for array elements in no time at all.
However, in certain circumstances you may need to use arrays with hundreds or thousands of elements. The following table shows the formula for calculating the memory usage for each array type:
|Array type||Formula for memory usage in bytes|
|Boolean||(31 + number of elements) / 8|
|date||(1 + number of elements) * 6|
|String||(1 + number of elements) * (sum of the size of each text)|
|Integer||(1 + number of elements) * 2|
|Long integer||(1 + number of elements) * 4|
|picture||(1 + number of elements) * 4 + sum of the sizes of each image in the array|
|pointer||(1 + number of elements) * 16|
|number||(1 + number of elements) * 8|
|text||(1 + number of elements) * (sum of the size of each text)|
|Two-dimensional||(1 + number of elements) * 12 + sum of the size of each array|
- The size of a text in the memory is calculated with the formula ((length + 1) * 2).
- The selected element, the number of elements, and the array itself take a few extra bytes.
When working with large arrays, you should check that there is enough memory. To do this, put the array creation at the beginning and query errors with an ON ERR CALL project method. Example:
The ERROR HANDLING project method is as follows:
- Is Ramadan all about fasting?
- Why should bedroom curtains match
- Who is a demiurge in Norse mythology
- What is the goal of entrepreneurship
- Why is Pak excluded
- Why didn't classical composers use percussion?
- Who has the supreme power in India
- How is life in Guam
- Why should you stay in serviced apartments?
- Are there female whores in the dominatrix
- What is traffic jam
- What is inevitable
- How many Merlions are there in Singapore
- What is the first step to wealth
- Manufacturing companies pay every six months
- How will the US economy survive Trump
- The Big 4 accept paid assistants
- What do operations managers do
- How does real happiness feel
- Would you let people ruin your day
- Can an LLC Inc.
- Why do people need acceptance from others
- Is Britain safe for ex-Muslims
- What or who lights you up
- Does minimalism hurt the economy
- What is inflation and what causes inflation
- Art galleries are no longer necessary
- Which countries consume the most candles?
- How can I fix a bent sheetrock
- When you meditate what is your mantra
- Have you ever eaten candied bacon?
- How much do food allergy tests cost
- What are the best motivational topics for the seminar
- How to get sick quickly