Skip to content

Suspected Memory Leak on Android builds #134

@mymoto23

Description

@mymoto23

Device: Galaxy Tab S7
OS: Android 13
Unity Editor: 2022.3f61
rive-unity: v0.3.8
Graphics API: OpenGLES3
(tried with OpenGLES2 and Vulkan as well. OpenGLES2 reproduces the issue, Vulkan messes up the rendering and crashes the app upon stage load)

I'm designing a game using unity and rive.
It consists of a brief introduction animation, a map and stages.

Map
Canvas - Rive Panel - Rive Widget
ㄴ Several Buttons

Stage
Canvas - Rive Panel - Multiple Rive Widgets

When I go back and forth from map and stage, about 6~7 cycles, the app crashes. with the full log:

2025/12/09 15:08:31.998 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:31.998 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.032 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.032 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.048 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.048 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.098 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.098 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.137 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.137 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.176 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.176 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.223 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.223 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.261 30394 30463 Warn Adreno-GSL <gsl_ldd_control:553>: ioctl fd 107 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
2025/12/09 15:08:32.261 30394 30463 Error Adreno-GSL <gsl_memory_alloc_pure:2609>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
2025/12/09 15:08:32.284 30394 30463 Error CRASH *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2025/12/09 15:08:32.284 30394 30463 Error CRASH Version '2022.3.62f1 (4af31df58517)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
2025/12/09 15:08:32.284 30394 30463 Error CRASH Build fingerprint: 'samsung/gts7xlwifixx/gts7xlwifi:13/TP1A.220624.014/T970XXS7DXH1:user/release-keys'
2025/12/09 15:08:32.284 30394 30463 Error CRASH Revision: '6'
2025/12/09 15:08:32.284 30394 30463 Error CRASH ABI: 'arm64'
2025/12/09 15:08:32.287 30394 30463 Error CRASH Timestamp: 2025-12-09 15:08:32.285020485+0900
2025/12/09 15:08:32.288 30394 30463 Error CRASH pid: 30394, tid: 30463, name: UnityGfxDeviceW  >>> com.-.-.test <<<
2025/12/09 15:08:32.288 30394 30463 Error CRASH uid: 10188
2025/12/09 15:08:32.288 30394 30463 Error CRASH signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr --------
2025/12/09 15:08:32.288 30394 30463 Error CRASH Cause: null pointer dereference
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x0  0000000000000001  x1  b4000072d0fbfd04  x2  0000000040920001  x3  0000000000000001
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x4  0000000000004b34  x5  0000000000000000  x6  0000000000000001  x7  0000000040920000
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x8  0000000000000014  x9  0000000000000014  x10 0000000000000014  x11 0000000000007fc0
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x12 0000000000000045  x13 0000000000000064  x14 0000000000000001  x15 0000000000000001
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x16 0000000000000001  x17 0000000000000001  x18 0000007237284000  x19 b4000072d0fbfc00
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x20 b4000072d1078d00  x21 0000000000000001  x22 0000000000000000  x23 b4000072d0fbfcd8
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x24 0000000000000001  x25 0000000000000014  x26 0000000000000000  x27 0000000000009669
2025/12/09 15:08:32.288 30394 30463 Error CRASH     x28 0000000000004168  x29 0000007238216e20
2025/12/09 15:08:32.288 30394 30463 Error CRASH     lr  00000073621c2570  sp  0000007238216e10  pc  00000073621c2758  pst 0000000060001000
2025/12/09 15:08:32.288 30394 30463 Error CRASH backtrace:
2025/12/09 15:08:32.288 30394 30463 Error CRASH       #00 pc 000000000039f758  /vendor/lib64/egl/libGLESv2_adreno.so (BuildId: 0ea54a261e90e97a4c98db7d1f7d7d4a)
2025/12/09 15:08:32.288 30394 30463 Error CRASH       #01 pc 00000000003819ac  /vendor/lib64/egl/libGLESv2_adreno.so (BuildId: 0ea54a261e90e97a4c98db7d1f7d7d4a)
2025/12/09 15:08:32.288 30394 30463 Error CRASH       #02 pc 0000000000176b68  /vendor/lib64/egl/libGLESv2_adreno.so (BuildId: 0ea54a261e90e97a4c98db7d1f7d7d4a)
2025/12/09 15:08:32.288 30394 30463 Error CRASH       #03 pc 000000000016e730  /vendor/lib64/egl/libGLESv2_adreno.so (BuildId: 0ea54a261e90e97a4c98db7d1f7d7d4a)
2025/12/09 15:08:32.288 30394 30463 Error CRASH       #04 pc 00000000003ae8dc  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/librive.so (rive::gpu::RenderContextGLImpl::flush(rive::gpu::FlushDescriptor const&)+5040)
2025/12/09 15:08:32.288 30394 30463 Error CRASH       #05 pc 00000000003bb894  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/librive.so (rive::gpu::RenderContext::flush(rive::gpu::RenderContext::FlushResources const&)+1776)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #06 pc 00000000003a5880  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/librive.so (rive::GLTextureTarget::end()+156)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #07 pc 00000000003a02f0  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/librive.so (RenderQueue::render(rive::RiveUnityRenderer*, unsigned int, bool)+1156)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #08 pc 000000000039fe2c  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/librive.so (renderCommandBuffer(int, void*)+64)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #09 pc 00000000008d4fc0  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/libunity.so (BuildId: 79f0b4997894c84c)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #10 pc 0000000000ab7704  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/libunity.so (BuildId: 79f0b4997894c84c)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #11 pc 0000000000aaf7a0  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/libunity.so (BuildId: 79f0b4997894c84c)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #12 pc 0000000000aaf4e8  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/libunity.so (BuildId: 79f0b4997894c84c)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #13 pc 00000000005078b0  /data/app/~~eHK0ndmkTZup6WKUH1QytQ==/com.-.-.test-EhQcsxcS1Am1ydCoJOiafw==/lib/arm64/libunity.so (BuildId: 79f0b4997894c84c)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #14 pc 00000000000f5298  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 1bcad8bca80d38bceb9089f70d394e33)
2025/12/09 15:08:32.289 30394 30463 Error CRASH       #15 pc 000000000008ebdc  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 1bcad8bca80d38bceb9089f70d394e33)

Here are the memory traces:

Android Logcat

Image

ADB log dump
After 2 back and forths:

Applications Memory Usage (in Kilobytes):
Uptime: 494729577 Realtime: 649287232

** MEMINFO in pid 1525 [com.-.-] **
                   Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------   ------
  Native Heap   108862   108728       76       52   109808   117740   116154     1585
  Dalvik Heap     2693     2640        4      157     3220     8702     2558     6144
 Dalvik Other     7935     1088        4        4    14968                           
        Stack     1492     1492        0        0     1500                           
       Ashmem       65        0        0        0      464                           
    Other dev   217872   217844       16        0   218248                           
     .so mmap    54674     7036    43908       20    75536                           
    .jar mmap    14531        0     9276        0    36476                           
    .apk mmap      807        0      420        0     2020                           
    .dex mmap     2529     2480        8        0     3052                           
    .oat mmap      247        0       84        0     1696                           
    .art mmap    12476     9440     1256      171    25012                           
   Other mmap     8069        8     8000        0     8648                           
   EGL mtrack    77776    77776        0        0    77776                           
    GL mtrack      384      384        0        0      384                           
      Unknown   245376   245232      104        4   245740                           
        TOTAL   756196   674148    63156      408   824548   126442   118712     7729
 
 App Summary
                       Pss(KB)                        Rss(KB)
                        ------                         ------
           Java Heap:    13336                          28232
         Native Heap:   108728                         109808
                Code:    63308                         132556
               Stack:     1492                           1500
            Graphics:    78160                          78160
       Private Other:   472280
              System:    18892
             Unknown:                                  474292
 
           TOTAL PSS:   756196            TOTAL RSS:   824548       TOTAL SWAP PSS:      408
 
 Objects
               Views:        7         ViewRootImpl:        1
         AppContexts:        5           Activities:        1
              Assets:       26        AssetManagers:        0
       Local Binders:       27        Proxy Binders:       52
       Parcel memory:        7         Parcel count:       27
    Death Recipients:        0      OpenSSL Sockets:        0
            WebViews:        0
 
 SQL
         MEMORY_USED:        0
  PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0 

After 4 back and forths (in the same session):

Applications Memory Usage (in Kilobytes):
Uptime: 494740247 Realtime: 649297902

** MEMINFO in pid 1525 [com.-.-] **
                   Pss  Private  Private  SwapPss      Rss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty    Total     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------   ------
  Native Heap   109902   109768       76       52   110848   118800   117133     1666
  Dalvik Heap     4602     1840      108       40     7996     8702     2558     6144
 Dalvik Other     8045     1088        4        3    15208                           
        Stack     1512     1512        0        0     1520                           
       Ashmem       65        0        0        0      464                           
    Other dev   339300   339272       16        0   339676                           
     .so mmap    54692     7040    43916       20    75720                           
    .jar mmap    14306        0     8968        0    36312                           
    .apk mmap      807        0      420        0     2020                           
    .dex mmap     2529     2480        8        0     3052                           
    .oat mmap      243        0       84        0     1684                           
    .art mmap    13599     9440     1248      122    27404                           
   Other mmap     8068        8     8000        0     8644                           
   EGL mtrack    77776    77776        0        0    77776                           
    GL mtrack      384      384        0        0      384                           
      Unknown   255524   255372      112        4   255888                           
        TOTAL   891595   805980    62960      241   964596   127502   119691     7810
 
 App Summary
                       Pss(KB)                        Rss(KB)
                        ------                         ------
           Java Heap:    12528                          35400
         Native Heap:   109768                         110848
                Code:    63020                         132740
               Stack:     1512                           1520
            Graphics:    78160                          78160
       Private Other:   603952
              System:    22655
             Unknown:                                  605928
 
           TOTAL PSS:   891595            TOTAL RSS:   964596       TOTAL SWAP PSS:      241
 
 Objects
               Views:        7         ViewRootImpl:        1
         AppContexts:        5           Activities:        1
              Assets:       26        AssetManagers:        0
       Local Binders:       26        Proxy Binders:       52
       Parcel memory:        7         Parcel count:       27
    Death Recipients:        0      OpenSSL Sockets:        0
            WebViews:        0
 
 SQL
         MEMORY_USED:        0
  PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0
 

Unity Profiler

Image

The thing is that when debugged on the Unity profiler, the memory usage seems stable, with no seeming leaks.
But as you can see, profiling the memory on Android Logcat results in a upward accumulation of memory usage, after which a certain point (I'm guessing 1GB) it crashes the app.

Any idea why this is happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions