# Loading of huge base64 glb?

**URL:** <https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191>\
**Category:** Questions\
**Created:** [September 15, 2020, 10:45am UTC](https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191 "2020-09-15T10:45:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Platin21](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Platin21](https://forum.babylonjs.com/u/Platin21)\
**Post date:** [September 15, 2020, 10:45am UTC](https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191/1 "2020-09-15T10:45:50Z")

</div>

Hello Fellow Babylon Developer,

I recently tried to load a 7mb base64 encoded glb file with babylon. The result was that it run out of memory the browser crashed and this happens all the time. When i just load the glb e.g via import which always fetches the entire thing it can load the model normally, this isn’t a solution though as i do have some binary data that i need to send with the model.

Now i load the model from webcache directly as base64 encoded as there seems to be no other way to load a glb from pure data.

Does anyone have an idea how i can possibly load the entire model? (No i can’t split it!)

---

<div class="post-metadata">

**Author:** ![Platin21](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Platin21](https://forum.babylonjs.com/u/Platin21)\
**Post date:** [September 15, 2020, 10:49am UTC](https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191/2 "2020-09-15T10:49:38Z")

</div>

I mainly need this so that the model is cached and doesn’t need to be reloaded everytime for like say a mobile user. I did read about the manifest files but they seem to not work correctly with a glb/gltf object.

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [September 15, 2020, 1:02pm UTC](https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191/3 "2020-09-15T13:02:24Z")

</div>

I do not know much about GLB, but am good with process & have more experience than I often admit. More than likely running out of memory is related to a bug on your side.

True, processes sometimes need for very short periods of time need 2 copies of something, limiting the max size by 0.5. 7mb seems a little small to be triggering that alone though.

I advise making a base64 file from a small GLB. If that does not go through, you definitely have a bug. Otherwise, you might need to either or all:

- actively force no longer need stuff out of scope, to keep your memory footprint down.
- break up the file in sections, so as to keep the amount of memory needed at one time lower.
- Change your process of conversion.

---

<div class="post-metadata">

**Author:** ![Platin21](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Platin21](https://forum.babylonjs.com/u/Platin21)\
**Post date:** [September 15, 2020, 1:58pm UTC](https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191/4 "2020-09-15T13:58:31Z")

</div>

Hmm current code is already pretty basic. Here a short list of the steps:

- Create Request
- Fetch Request
- Pass Data to Babylon.AppendAsync

So i’m not sure why it fails on such a tiny file like you said.

For 1. of your list there is nothing else besides the egine/secne that is activ in the scope.  
2. is no possible as you can’t load a gltf partially e.g it’s one thing as also that would bloat the size probbably more as currently the gltf is draco compressed + in binary form e.g glb.  
3. If i would know where to put the binary data or the u8 array that is the file in memory then i could do this but i’m not sure if that is even possible. I used the base64 steps only base the examples don’t show how one would do it with raw data.

---

<div class="post-metadata">

**Author:** ![Platin21](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Platin21](https://forum.babylonjs.com/u/Platin21)\
**Post date:** [September 16, 2020, 9:10am UTC](https://forum.babylonjs.com/t/loading-of-huge-base64-glb/14191/5 "2020-09-16T09:10:29Z")

</div>

The Easy solution to this problem is to use a service worker which chaches all of the scripts + glb files so that i never needs to be fetched again. I now do my modifications inside the worker and return babylon only the finished results…
