Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemory error while saving #14

Open
TheMax2000 opened this issue Nov 16, 2016 · 6 comments
Open

OutOfMemory error while saving #14

TheMax2000 opened this issue Nov 16, 2016 · 6 comments

Comments

@TheMax2000
Copy link

I got this error in the console while trying to save a scene from GILES.
I have a (single) kinda complex prefab, but all submeshes should be fine to serialize.
Is there a way I could work around this error?
I tried to build a 64bits version, but the same error appears.

OutOfMemoryException: Out of memory
System.Text.StringBuilder.InternalEnsureCapacity (Int32 size) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Text/StringBuilder.cs:725)
System.Text.StringBuilder.Append (System.Char[] value, Int32 startIndex, Int32 charCount) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Text/StringBuilder.cs:480)
System.IO.StringWriter.Write (System.Char[] buffer, Int32 index, Int32 count) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StringWriter.cs:142)
Newtonsoft.Json.JsonTextWriter.WriteIndent ()
Newtonsoft.Json.JsonWriter.AutoComplete (JsonToken tokenBeingWritten)
Newtonsoft.Json.JsonWriter.InternalWritePropertyName (System.String name)
Newtonsoft.Json.JsonTextWriter.WritePropertyName (System.String name)
Newtonsoft.Json.Linq.JProperty.WriteTo (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter[] converters)
Newtonsoft.Json.Linq.JObject.WriteTo (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter[] converters)
Newtonsoft.Json.Linq.JArray.WriteTo (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter[] converters)
Newtonsoft.Json.Linq.JProperty.WriteTo (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter[] converters)
Newtonsoft.Json.Linq.JObject.WriteTo (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter[] converters)
GILES.Serialization.pb_MeshConverter.WriteObjectJson (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.JsonSerializer serializer) (at Assets/GILES/Code/Classes/Serialization/Converters/pb_MeshConverter.cs:47)
GILES.Serialization.pb_UnityTypeConverter`1[T].WriteJson (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.JsonSerializer serializer) (at Assets/GILES/Code/Classes/Serialization/Converters/pb_UnityTypeConverter.cs:29)
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter converter, System.Object value, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty)
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty)
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeDictionary (Newtonsoft.Json.JsonWriter writer, IDictionary values, Newtonsoft.Json.Serialization.JsonDictionaryContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty)
UnityEngine.EventSystems.EventSystem:Update()
@karl-
Copy link
Contributor

karl- commented Nov 16, 2016

I'd guess that instead of referencing the mesh GILES is trying to write all the vertex & tri data. How big (vertex/tri count-wise) is this mesh? If you replace it with a lower poly version does this error still occur?

@TheMax2000
Copy link
Author

If I delete manually (in editor, while running) a lot of subobjects of the prefab it does save.
Since the prefab is quite complex, I'll take the time to analyze what subobject(s) is causing the problem. I have a few 65k vertices objects that I could get rid of, or simplify at least...

However, is there a way to make GILES writting in binary format (which should be quite smaller) or avoiding to write all the vertex & triangles data?

@karl-
Copy link
Contributor

karl- commented Nov 16, 2016

It should be avoiding writing the mesh data currently; if it's doing that now that is a bug.

On writing binary, that would be a good feature request.

@TheMax2000
Copy link
Author

It seems it writes the mesh data for all children of the prefab.
I'm not a pro of Unity, but I'll give a look to the code to check if I can find something...

@TheMax2000
Copy link
Author

Ok, it seems that all the children information is not needed. So I can have a 3kb file that loads correctly the full object, instead of a >500MB (deleting half of the children). I'm still trying to figure out why though... it should not serialize those children at all.

@TheMax2000
Copy link
Author

I did a workaround fix: I do not generate children if it's a resource. However I don't think it's the ideal solution, but since I don't need any resource's child, I think it will work for me for now.

pb_SceneNode.cs from ln 90

// avoid calling constructor which automatically rebuilds the matrix
 transform = new pb_Transform();
 transform.SetTRS(root.transform);

 children = new List<pb_SceneNode>();
 if (metadata.assetType != AssetType.Resource)
 {               
      foreach (Transform t in root.transform)
       {
            if (!t.gameObject.activeSelf)
                 continue;

            children.Add(new pb_SceneNode(t.gameObject));
      }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants