简体   繁体   English

如何检查仍在使用哪个线程或对象?

[英]How to check what thread or object is still used or not?

could anyone tell me how I can see which activities / threads remain active and are no longer called by my application? 谁能告诉我如何查看哪些活动/线程保持活动状态,而不再由我的应用程序调用?

For example, if I open an HTTP stream and then don't flush, but continue to open new ones, the memory used will continue to go up until the GC passes to clean up. 例如,如果我打开一个HTTP流,然后不刷新,而是继续打开新的流,则使用的内存将继续增加,直到GC通过清理为止。 is it possible to somehow see which threads or objects etc that have been generated and are not used for a given time x? 是否有可能以某种方式查看在给定的时间x内已生成并未使用的线程或对象等?

The reason for this request is due to the fact that having a server deployed with an application, this continues to increase the memory incrementally up to the limit whereby the GC is forced to intervene to re-establish a stable memory situation. 发出此请求的原因是由于在服务器上部署了应用程序,这会继续增加内存,直到达到限制,从而迫使GC干预以重新建立稳定的内存情况。

I don't know if it can be helpful in this analysis but the gcc parameters are set to: 我不知道这对分析是否有帮助,但是gcc参数设置为:

-Xms8g -Xmx8g -XX: PermSize = 1024 XX: MaxPermSize = 1024 -Xms8g -Xmx8g -XX:PermSize = 1024 XX:MaxPermSize = 1024

the machine's ram is 18g. 机器的公羊是18克。

thanks to all in advance 预先感谢所有人

To check whether an object is still used, perform a full GC. 要检查是否仍使用对象,请执行完整的GC。 There isn't a short cut for this action. 此操作没有捷径可走。

You don't know if an object is needed until a garbage collection is performed. 在执行垃圾回收之前,您不知道是否需要对象。

the memory used will continue to go up until the GC passes to clean up. 直到GC通过清理为止,使用的内存将继续增加。

This is normal in a JVM. 这在JVM中很正常。 To improve performance, you want to reuse expensive objects, and not worry too much about cheap objects. 为了提高性能,您想重用昂贵的对象,而不必过多担心廉价的对象。 You also need to tune the GC so that when it does run, it doesn't impact your application too much. 您还需要调整GC,以使其在运行时不会对应用程序造成太大影响。

NOTE: Perm Gen was dropped in Java 8, and from March 2019, only Java 12 has free updates from Oracle, so will need to consider upgrading at some point. 注意:Perm Gen已从Java 8中删除,从2019年3月开始,只有Java 12可以从Oracle免费更新,因此需要在某个时候考虑进行升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM