gpt4 book ai didi

android - 在Android开发中,这个: "The debugger and garbage collector are currently loosely integrated."有什么含义

转载 作者:太空狗 更新时间:2023-10-29 14:28:11 24 4
gpt4 key购买 nike

靠近这个 page about Debugging 的底部在 Android 开发者网站上它说

The debugger and garbage collector are currently loosely integrated. The VM guarantees that any object the debugger is aware of is not garbage collected until after the debugger disconnects. This can result in a buildup of objects over time while the debugger is connected. For example, if the debugger sees a running thread, the associated Thread object is not garbage collected even after the thread terminates.

那么这里的确切含义是什么?我是否假设:

  1. 线程内的任何日志调用都会导致该线程永远不会被收集?
  2. 在 UI 线程中的方法中的任何 Log 调用,如果是从线程 X 中调用的,意味着永远不会收集线程 X?
  3. 方法内部的任何日志调用,甚至包含线程或可运行的新实例的构造都可能无法进行垃圾收集?

如果这是真的:

  1. 这是否仅适用于应用程序在 AndroidManifest.xml 中明确标记为可调试的情况?
  2. 即使设备未主动连接到调试器,它也适用吗?

最佳答案

除非当前附加了调试器,否则 GC 将正常运行。对 Log 的调用在任何方面都不是特别的。虽然附加了调试器,但不能保证任何对象都将被收集,因为调试器可能持有对它感觉的任何东西的额外引用。一旦调试器断开连接,下一次 GC 将正常发生并收集之前保留的对象。无法准确说明哪些对象不会被收集,因为调试器可以做任何它认为需要做的事情。

只是阅读 logcat 输出并不是“附加调试器”。它特指实际的 Java 调试器,例如设置断点,单步执行。

关于android - 在Android开发中,这个: "The debugger and garbage collector are currently loosely integrated."有什么含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9742101/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com