首页 >> 大全

Java运行期追踪堆栈信息

2023-10-07 大全 30 作者:考证青年

字符串常量池与堆空间

运行后 为了不会被回收空间,sleep一小时

jps命令查询Java程序

使用jamp查询堆空间

jmap -dump:=b,file=aa.bin(aa.bin=随意名字) pid(pid=Java线程id)

jhat aa.bin

显示例外堆栈跟踪_java看堆栈命令_

访问 :7000/

我是访问的是:7000/oql/

OQL Java虚拟机语言 查询字符串地址

s.value.() from java.lang. s

where //.test(s.value.())

查询结果只有一个 说明只在堆中存在,而字符串常量池中保存的是引用地址

java看堆栈命令__显示例外堆栈跟踪

gfdss 查询结果有两个 说明只在堆中存在,而字符串常量池中保存的是也是字符串,所以地址不一样

在使用"" 时 编译期就会存入常量池,也会在堆中放入,但是在后就被修改为,所以查询结果只剩下一个。

lsof -i:7000

查询7000端口使用者

方法的解释

/*** Returns a canonical representation for the string object.* 

* A pool of strings, initially empty, is maintained privately by the* class {@code String}.*

* When the intern method is invoked, if the pool already contains a* string equal to this {@code String} object as determined by* the {@link #equals(Object)} method, then the string from the pool is* returned. Otherwise, this {@code String} object is added to the* pool and a reference to this {@code String} object is returned.*

* It follows that for any two strings {@code s} and {@code t},* {@code s.intern() == t.intern()} is {@code true}* if and only if {@code s.equals(t)} is {@code true}.*

* All literal strings and string-valued constant expressions are* interned. String literals are defined in section 3.10.5 of the* The Java™ Language Specification.** @return a string that has the same contents as this string, but is* guaranteed to be from a pool of unique strings.*/public native String intern();

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了