hello, everybody
 开发过程中遇到一个问题,不知道各位有没有碰见过,下面是个简单的测试例子,做一个简单描述
代码中就是想加载指定jar包中的配置文件,现在我将jar读入后(标红处),不做任何处理,只是轮训一下它里面包含些文件夹或文件,然后关闭.
public class MySelfTest { public static void main(String[] args) {

if (args == null) {
System.out.println("Please input the thread number");
return;
}
//get the directory path
final String libPath = ProgramPathHelper.getProgramPath() + File.separator + "lib/";

//search wips_umts.jar

File directory = new File(libPath);
final File libJarFile[] = directory.listFiles(new FileFilter() {
@Override
public boolean accept(File arg0) {
return "wips_umts.jar".equals(arg0.getName());
}
});
if (libJarFile == null || libJarFile.length != 1) {
System.out.println("Do not find the wips_umts.jar in the " + libPath);
return;
}

for (int i = 0; i < Integer.valueOf(args[0]); i ++) {
new Thread(new Runnable() {

@Override
public void run() {
new MySelfTest().test(libJarFile[0]);
}
}).start();
}
}

public void test(File file) {
JarFile jarFile = null;
try {
jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry nextElement = entries.nextElement();
}

} catch (IOException e) {
e.printStackTrace();
} finally {
try {
(jarFile).close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
到此后,输入参数10(线程数),放到服务器上测试(solaris系统64个cpu),用pmap检查发现native heap会不停增长,还请以前用过JarFile类,并且遇到问题的朋友解答,谢谢
bash-3.2$ while true; do pmap -ax 27835 | grep heap; sleep 10; done 
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   24576   24576   24576       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   28672   28672   28672       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   32768   32768   32768       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   36864   36864   36864       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   40960   40960   40960       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   45056   45056   45056       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   45056   45056   45056       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   49152   49152   49152       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   53248   53248   53248       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   57344   57344   57344       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   61440   61440   61440       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   65536   65536   65536       - rwx--    [ heap ]
0002C000      16      16      16       - rwx--    [ heap ]
00030000    3904    3904    3904       - rwx--    [ heap ]
00400000   65536   65536   65536       - rwx--    [ heap ]JavaheapNative App