用于查找会话引用的给定类的所有实例和子实例的 OQL 查询
我正在尝试使用 jhat/OQL 来跟踪 Tomcat 容器中的内存泄漏。我想问的问题是:
“显示可从 javax.servlet.http.HttpSession 访问的 foo.bar.Cacheable 类的所有实例(和子实例)”
我设法来了与以下内容一起,但这不显示 foo.bar.Cacheable 的子类(这很重要,因为这实际上是一个接口)。
select filter(reachables(s), "/foo.bar.Cacheable/(classof(it).name)") from javax.servlet.http.HttpSession s
我尝试了下面概念的各种排列,但不断收到错误(“foo”未定义)。
select filter(reachables(s), classof(it) instanceof foo.bar.Cacheable) from javax.servlet.http.HttpSession s
任何人都可以帮我解决通过 OQL 提出这个问题的错误吗?
I'm trying to use jhat/OQL to trace a memory leak in our Tomcat container. The question I want to ask is:
"Show me all the instances (and sub-instances) of foo.bar.Cacheable class that are reachable from javax.servlet.http.HttpSession"
I managed to come up with the following, but this doesn't show subclasses of foo.bar.Cacheable (which is important since this is infact an interface).
select filter(reachables(s), "/foo.bar.Cacheable/(classof(it).name)") from javax.servlet.http.HttpSession s
I tried various permutations of the concept below, but just keep getting errors ("foo" is not defined).
select filter(reachables(s), classof(it) instanceof foo.bar.Cacheable) from javax.servlet.http.HttpSession s
Can anyone help me out with what I'm doing wrong to pose this question through OQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在基于 jhat 的 OQL 实现(jHat、VisualVM)中,您可以利用这样一个事实:您不仅限于类似 SQL 的语法,而且拥有完整的 javascript 引擎。
下面的代码可以解决这个问题
In jhat based OQL implementations (jHat, VisualVM) you can exploit the fact that you are not limited to the SQL like syntax but you have a complete javascript engine at your hands.
The following piece of code would do the trick