-
-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently trying to save a file over 2gib results in this exception:
System.OutOfMemoryException: Cannot allocate a buffer of size 2147487611.
at System.Text.Json.ThrowHelper.ThrowOutOfMemoryException(UInt32 capacity)
at System.Text.Json.Utf8JsonWriter.Grow(Int32 requiredSize)
at SharpGLTF.IO._JSonSerializationExtensions.TryWriteValue(Utf8JsonWriter writer, Object value)
I believe this is due to the use of MemoryStream (which itself is limited to 2gib). Specifically here:
SharpGLTF/src/SharpGLTF.Core/Schema2/Serialization.WriteContext.cs
Lines 226 to 233 in dc19976
| using (var m = new MemoryStream()) | |
| { | |
| model._WriteJSON(m, this.JsonOptions, this.JsonPostprocessor); | |
| string finalName = Path.HasExtension(name) ? name : $"{name}.gltf"; | |
| WriteAllBytesToEnd(finalName, m.ToArraySegment()); | |
| } |
I believe switching this to a direct FileStream would solve this, and not require keeping the entire JSON object in memory.
EDIT: This can also be done in WriteBinarySchema2.
This may also require calling Utf8JsonWriter.Flush() in strategic places.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request