RealDocs

TArray::BulkSerialize

function Core Since 4.0
#include "Containers/Array.h"
Access: public

Description

Serializes the entire array as a raw memory blob during loading, bypassing per-element serialization for significant performance gains. On saving, it uses the regular element-by-element path to verify correctness.

Caveats & Gotchas

  • ElementType must have no constructor/destructor logic, no pointers, and its << operator must serialize ALL members in the exact memory layout order. Violating these constraints causes silent data corruption that only manifests on load.
  • Only safe on platforms with matching endianness, or when the cooking pipeline has already handled byte-swapping. Do not use for cross-platform raw data without confirming endian handling.
  • During save, BulkSerialize falls back to per-element serialization (except when cooking or transacting) so mismatches between operator<< and actual layout are caught during development — but not in shipped builds.
  • TCanBulkSerialize<T> is the compile-time opt-in trait; if your type doesn't specialize it, BulkSerialize still works but you must ensure the constraints manually.

Signature

void BulkSerialize(FArchive& Ar, bool bForcePerElementSerialization = false)

Parameters

Name Type Description Default
Ar FArchive& Archive to serialize to or from.
bForcePerElementSerialization bool When true, always falls back to per-element serialization regardless of archive state. false

Return Type

void

Example

Serializing a plain-data struct array C++
// Plain-data struct — no pointers, no constructors
struct FRawVertex
{
    float X, Y, Z;
    friend FArchive& operator<<(FArchive& Ar, FRawVertex& V)
    {
        return Ar << V.X << V.Y << V.Z;
    }
};

FArchive& operator<<(FArchive& Ar, UMyMeshAsset& Asset)
{
    // Fast path: single Serialize() call for the entire buffer on load
    Asset.Vertices.BulkSerialize(Ar);
    return Ar;
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.