java缓存代码,为什么java代码缓存大小在增长?

I have this basic program which does nothing but sit there waiting for input:

import java.io.*;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class Basic {

public static void main(String[] args) throws Exception{

try{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String input;

input=br.readLine();

}catch(IOException io){

io.printStackTrace();

}

}

}

And when I run this:

java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=15001 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false Basic

I connect via JConsole to see this:

oXQTU.png

Is that simply because core java bytcode is being compiled at first? How can the codecache be increasing when the process is not doing anything?

And when I have this version (which uses Thread.sleep):

public class Basic {

public static void main(String[] args) throws Exception{

while(true) {

Thread.sleep(5000);

}

}

}

I get this:

quw9r.png

So... why is this happening?

P.S. this is the output of java -version:

java version "1.6.0_37"

Java(TM) SE Runtime Environment (build 1.6.0_37-b06)

Java HotSpot(TM) Client VM (build 20.12-b01, mixed mode, sharing)

解决方案

I suspect that it is jconsole itself that is causing the problem. Or more precisely, the jmxremote stuff that allows jconsole to see what is going on inside your JVM.

My advice:

Don't worry about it. It looks like it has almost reached a steady state.

If that's not good enough, then leave jconsole running for a very long time and observe if the memory usage growth stops completely.

If that's not good enough, then you could try to profile it ... though tracking down small storage leaks in the jmxremote code (with or without source code) could be challenging.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值