【发布时间】:2021-11-24 20:27:37
【问题描述】:
根据 JNA 的 Memory 类文档,当需要释放不再引用的内存时,需要调用 finalize() 方法。但是在JNA example 中,提到了内存对象在超出范围时被释放。
// note: like Memory, StringArray will free the contiguous block of memory it copied the Strings into when the instance goes out of scope
问题是:
-
这是否意味着,当 Memory 类对象超出范围并释放底层本机内存时,它在内部调用 finalize()?
-
StringArray 类和 Memory 类在行为 w.r.t 上是相同的。内存管理?以及如何?
【问题讨论】:
标签: java memory-management memory-leaks native jna