ART视角 | 如何在native内存增长过多时自动触发GC?如何在Java对象回收时触发native内存回收?
发布日期:2021-04-30 21:10:21 浏览次数:115 分类:精选文章

本文共 1668 字,大约阅读时间需要 5 分钟。

??

GC??Java??????????????????????????????Android??????Java????????????????????????????????????native???????Bitmap????????????????????????????native???????????????

????????????GC???????????GC??????????????????????

  • ???native???????????GC
  • ???GC??Java???????native??
  • ???native???????????GC

    Android?N?????NativeAllocationRegistry????????????GC??Java???????native?????????????????????????Java?????Java??????????????native???????????Java???????native??????????????Java????????????GC???????native??????????????????????????NativeAllocationRegistry??GC????????????native?????????????GC?

    ??????????GC?????Java???????????native??????????????NativeAllocationRegistry???????Java??native???????????native????????????

    ???Java???????native????

    NativeAllocationRegistry?????Cleaner????????????Cleaner???????????????

    ????

    Bitmap?????NativeAllocationRegistry???native???????????Bitmap?????????

    mNativePtr = nativeBitmap; final int allocationByteCount = getAllocationByteCount(); NativeAllocationRegistry registry; if (fromMalloc) { registry = NativeAllocationRegistry.createMalloced(Bitmap.class.getClassLoader(), nativeGetNativeFinalizer(), allocationByteCount); } else { registry = NativeAllocationRegistry.createNonmalloced(Bitmap.class.getClassLoader(), nativeGetNativeFinalizer(), allocationByteCount); } registry.registerNativeAllocation(this, nativeBitmap);

    ??????????????NativeAllocationRegistry??Java?????native????????????NativeAllocationRegistry???????registerNativeAllocation????????????native????????

    ??

    ??????Android-360????????????????????????????????????????APP??????????????????????????PDF??????????Android?????????????721?????????????????Android?????????????????????????

    上一篇:Redis各种数据类型的适用场景
    下一篇:阿里十年工作经验总结MySQL笔记

    发表评论

    最新留言

    哈哈,博客排版真的漂亮呢~
    [***.90.31.176]2026年06月05日 04时23分55秒