Mutable Type Builder Over-Allocation Strategy
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing implementations of mutable types, such as arrays and strings, require post-operation memory allocation and copying of elements, leading to inefficiencies and additional garbage collection, especially when the number of data elements is not known in advance.
Innovation Solution
A method is introduced to build mutable types by over-allocating an internal buffer, allowing elements to be added or removed without resizing, and then garbage collecting the unused portion, eliminating the need for post-operation memory allocation and copying.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If traditional memory allocation methods are used for mutable types, then memory management is straightforward, but post-operation memory allocation and copying of elements is required, leading to inefficiency and additional garbage collection
Solution Approach 1:
The patent applies preliminary action by over-allocating memory buffer space during the initial creation of mutable types (arrays and strings). Instead of allocating memory based on exact element count, the system pre-allocates a larger buffer that can accommodate future element additions without requiring reallocation. This preliminary over-allocation eliminates the need for post-operation memory allocation and copying, directly resolving the technical contradiction by improving productivity while reducing time loss.
2Quantity of substance
If exact memory allocation is used based on known element count, then memory usage is optimized, but additional memory allocation and copying is needed when element count is not known in advance
Solution Approach 1:
The patent applies partial or excessive action by intentionally over-allocating memory buffer space beyond the immediate needs of the mutable type. Rather than allocating exactly the required amount of memory, the system allocates a larger buffer that exceeds current element requirements. This excessive allocation simplifies memory management by eliminating the need for complex reallocation and copying operations when elements are added, trading some initial memory overhead for reduced operational complexity.
3Adaptability or versatility
If mutable types are implemented with dynamic resizing, then flexibility is improved, but unnecessary memory reallocations and garbage collection occur
Solution Approach 1:
The patent applies preliminary action by pre-allocating sufficient memory buffer space during the creation of mutable types to accommodate expected element additions. This preliminary over-allocation provides the flexibility needed for dynamic manipulation of arrays and strings without triggering memory reallocation operations. By having sufficient buffer space available from the start, the system maintains adaptability while avoiding the energy-consuming garbage collection cycles that would otherwise be required to manage reallocated memory.
Data Source
Figure 1
Figure 2~3
Figure 4~5
AI summary
A computing device implemented method for building a mutable type is disclosed. A data structure is generated in a contiguous section of memory. The data structure includes an element portion and an over-allocation portion. The element portion stores elements accessible with an index. A gap object is inserted into the over-allocation portion. The gap object is garbage collected.