termux / termux-x11

Termux X11 add-on application.
https://termux.dev
GNU General Public License v3.0
1.85k stars 290 forks source link

[Bug]: ION Memory Not Released After Closing GPU-Accelerated Applications in Termux X11 #611

Closed b374sec closed 3 months ago

b374sec commented 3 months ago

Problem description

When running any application that utilizes GPU acceleration through Zink in Termux X11, the ION memory usage significantly increases as expected. However, this increased allocation does not decrease back to its original level after the application is terminated. This behavior leads to a gradual accumulation of used ION memory that is not released, affecting the overall performance and usability of the device until it completely hangs up.

Environment:

Device Information: OnePlus 7 Pro
Termux Version: Latest
Termux X11 Version: Latest
Mesa Driver: Turnip DRI3
GPU Acceleration Library: Zink
Linux: Ubuntu 22.04 Chroot

What steps will reproduce the bug?

  1. Open Termux X11and start via termux-x11 or termux-x11 -ac

  2. Enter chroot environment

  3. Start any GPU-accelerated application using the Zink library

    MESA_LOADER_DRIVER_OVERRIDE=zink glmark2 -b terrain --run-forever --fullscreen
  4. Close the application normally and restart it several times

  5. Check used ION memory which increases with every app start but does not decrease after stopping the application

    
    adb shell
    dumpsys meminfo

Output

Total RAM: 5,583,492K (status normal) Free RAM: 434,608K ( 144,056K cached pss + 75,336K cached kernel + 215,216K free) ION: 4,002,788K (3,703,976K mapped + 298,812K unmapped + 0K pools) GPU: 0K Used RAM: 5,441,876K (4,817,024K used pss + 624,852K kernel) Lost RAM: 360,827K ZRAM: 302,552K physical used for 971,336K in swap (3,145,724K total swap) Tuning: 256 (large 512), oom 322,560K, restore limit 107,520K (low-ram)



Stopping all chroot processes does not decrease used ION. Only terminating the termux-x11 process started through termux environment leads to decrease of the used ION.

### What is the expected behavior?

ION memory is released as soon as the GPU-accelerated applications is closed.
twaik commented 3 months ago

@xMeM do you have any suggestions?

xMeM commented 3 months ago

The munmap in the lorieDestroyPixmap function is never called.

b374sec commented 3 months ago

Thanks, it's fixed!