Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Out of memory WebGL random

Discussion in 'Web' started by LoopIssuer, Apr 4, 2023.

  1. LoopIssuer


    Jan 27, 2020
    In our application build with Unity 2021.3.20f1 for WebGL, on Chrome and Firefox, we get sometimes 'out of memory' error.
    Can anybody say something that could be a reason?
    It happens on the scene where are:
    -video player rendering to RenderTexture on Sphere
    -VideoKit from NatML (and I need permission for using a camera and microphone)
    -small amount of UI

    This is a log from browser:

    Code (CSharp):
    1. exception thrown: RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds
    2.     at MemoryProfiler::UnregisterAllocation(void*, unsigned long, MemLabelId const&) ([133919]:0x292a35d)
    3.     at MemoryManager::Deallocate(void*, MemLabelId const&, char const*, int) ([134055]:0x2937ffa)
    4.     at free_alloc_internal(void*, MemLabelId const&, char const*, int) ([134070]:0x2939b9b)
    5.     at dynamic_array<DynamicVBOBuffer, 0ul>::~dynamic_array() ([129479]:0x275bbfc)
    6.     at SharedMeshData::~SharedMeshData() ([129529]:0x275f9c9)
    7.     at Mesh::ReleaseAndAssignMeshData(SharedMeshData*) ([130418]:0x27d1c1a)
    8.     at Mesh::~Mesh() ([130474]:0x27e2959)
    9.     at DestroySingleObject(Object*) ([133715]:0x291d81b)
    10.     at DestroyObjectHighLevel_Internal(Object*, bool) ([131309]:0x2852ce0)
    11.     at DestroyObjectHighLevel(Object*, bool) ([131310]:0x2852d05)
    12.     at Object_CUSTOM_DestroyImmediate(Il2CppObject*, unsigned char) ([132494]:0x28baf45)
    13.     at Object_DestroyImmediate_m737E5829FEEAE70EE7A004D172042D52E336E1E3 ([86880]:0x1807c69)
    14.     at Object_DestroyImmediate_m6336EBC83591A5DB64EC70C92132824C6E258705 ([86881]:0x1807c9f)
    15.     at TextMeshProUGUI_OnDestroy_mF6F5098912944CBAEE8F9162CBC8513B6FCB4DCB ([17478]:0x4ae1a3)
    16.     at RuntimeInvoker_TrueVoid_t4861ACF8F4594C3437BB48B6E56783494B843915(void (*)(), MethodInfo const*, void*, void**, void*) ([107106]:0x1b94576)
    17.     at il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) ([109186]:0x1bbc334)
    18.     at dynCall_iiii ([134422]:0x29528cf)
    19.     at
    20.     at invoke_iiii (
    21.     at il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) ([109160]:0x1bbb7f2)
    22.     at il2cpp_runtime_invoke ([109230]:0x1bbde65)
    23.     at scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) ([133519]:0x2907910)
    24.     at ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) ([131494]:0x2871db6)
    25.     at ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*) ([131499]:0x2871fb5)
    26.     at SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr) ([111831]:0x1c42a86)
    27.     at MonoBehaviour::WillDestroyComponent() ([131431]:0x286c706)
    28.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x2851912)
    29.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x28519d1)
    30.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x28519d1)
    31.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x28519d1)
    32.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x28519d1)
    33.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x28519d1)
    34.     at PreDestroyRecursive(GameObject&, unsigned long*) ([131306]:0x28519d1)
    35.     at DestroyObjectHighLevel_Internal(Object*, bool) ([131309]:0x28528ff)
    36.     at DestroyObjectHighLevel(Object*, bool) ([131310]:0x2852d05)
    37.     at RuntimeSceneManager::UnloadSceneInternal(UnityScene*, UnloadSceneOptions) ([112011]:0x1c5519d)
    38.     at UnloadSceneOperation::IntegrateMainThread() ([111940]:0x1c4e1b2)
    39.     at PreloadManager::UpdatePreloadingSingleStep(PreloadManager::UpdatePreloadingFlags, int) ([111933]:0x1c4d10b)
    40.     at PreloadManager::UpdatePreloading() ([111935]:0x1c4d3ff)
    41.     at InitPlayerLoopCallbacks()::EarlyUpdateUpdatePreloadingRegistrator::Forward() ([131152]:0x284140c)
    42.     at ExecutePlayerLoop(NativePlayerLoopSystem*) ([111874]:0x1c46e96)
    43.     at ExecutePlayerLoop(NativePlayerLoopSystem*) ([111874]:0x1c46f32)
    44.     at MainLoop() ([129004]:0x27020c2)
    45.     at dynCall_v ([134425]:0x29528ef)
    46.     at
    47.     at browserIterationFunc (
    48.     at callUserCallback (
    49.     at Object.runIter (
    50.     at Browser_mainLoop_runner (
  2. CodeSmile


    Apr 10, 2014
    Try profiling, specifically using the memory profiler package. This isn't a case where anyone would say "Of course, it's obvious, just do XXX". ;)

    Check and experiment with the WebGL player settings related to memory. For example the usual 20% memory size increase may not be suitable for your case, or you may see better stability if you increase the initially allocated memory thus reducing the need to allocate more memory on the fly which depends on having enough contiguous free memory available.

    But first profile to see if you have any memory leaks. To make this easier, closely observe memory usage in editor playmode since leaks or short but high usage spikes may already be visible in the editor.