@@ -103,7 +103,30 @@ which are equivalent to new, delete, new[] and delete[].
103
103
memnew/memdelete also use a little C++ magic and notify Objects right
104
104
after they are created, and right before they are deleted.
105
105
106
- For dynamic memory, use Vector<>.
106
+ For dynamic memory, use one of Godot's sequence types such as ``Vector<> ``
107
+ or ``LocalVector<> ``. ``Vector<> `` behaves much like an STL ``std::vector<> ``,
108
+ but is simpler and uses Copy-On-Write (CoW) semantics. CoW copies of
109
+ ``Vector<> `` can safely access the same data from different threads, but
110
+ several threads cannot access the same ``Vector<> `` instance safely.
111
+ It can be safely passed via public API if it has a ``Packed `` alias.
112
+
113
+ The ``Packed*Array `` :ref: `types <doc_gdscript_packed_arrays >` are aliases
114
+ for specific ``Vector<*> `` types (e.g., ``PackedByteArray ``,
115
+ ``PackedInt32Array ``) that are accessible via GDScript. Outside of core,
116
+ prefer using the ``Packed*Array `` aliases for functions exposed to scripts,
117
+ and ``Vector<> `` for other occasions.
118
+
119
+ ``LocalVector<> `` is much more like ``std::vector `` than ``Vector<> ``.
120
+ It is non-CoW, with less overhead. It is intended for internal use where
121
+ the benefits of CoW are not needed. Note that neither ``LocalVector<> ``
122
+ nor ``Vector<> `` are drop-in replacements for each other. They are two
123
+ unrelated types with similar interfaces, both using a buffer as their
124
+ storage strategy.
125
+
126
+ ``List<> `` is another Godot sequence type, using a doubly-linked list as
127
+ its storage strategy. Prefer ``Vector<> `` (or ``LocalVector<> ``) over
128
+ ``List<> `` unless you're sure you need it, as cache locality and memory
129
+ fragmentation tend to be more important with small collections.
107
130
108
131
References:
109
132
~~~~~~~~~~~
0 commit comments