java -Xms512m -Xmx1024m -classpath socket-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.socket.App 4500 20
我想要问的是为什么我设置了-Xmx1024m这个参数可是程序运行占用的内存还是不断上升,用了3G多了
我是用20分钟在里面创4500个线程
大神求指教
14 回复
@wendal 我是在Windows下跑的,然后通过任务管理器看的
@wendal 不好意思久等了
C:\Users\Administrator>jmap -heap 8832
Attaching to process ID 8832, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.131-b11
using thread-local object allocation.
Parallel GC with 4 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 178782208 (170.5MB)
MaxNewSize = 357564416 (341.0MB)
OldSize = 358088704 (341.5MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 127401984 (121.5MB)
used = 119145672 (113.62616729736328MB)
free = 8256312 (7.873832702636719MB)
93.51947925708912% used
From Space:
capacity = 24117248 (23.0MB)
used = 16473000 (15.709877014160156MB)
free = 7644248 (7.290122985839844MB)
68.30381310504416% used
To Space:
capacity = 25690112 (24.5MB)
used = 0 (0.0MB)
free = 25690112 (24.5MB)
0.0% used
PS Old Generation
capacity = 358088704 (341.5MB)
used = 13603824 (12.973617553710938MB)
free = 344484880 (328.52638244628906MB)
3.799009532565428% used
8843 interned Strings occupying 767360 bytes.
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
这些算是nio吗,我刚刚查了一下资料还是不太确定???
看到了有资料说在java API中提供了两套NIO,一套是针对标准输入输出NIO,另一套就是网络编程NIO,我的这个又引用了Buffer操作,又引入了socket操作算是引入了两套nio了吗
@wendal
@wendal 我使用了mat看到那个饼状图显示了我的程序才占了一点点,remainder占的超过90%多,Histogram显示我的Thread线程对象已经起到5000了,第一次使用这个东西,看了网上一些人的介绍,不怎么会分析,不知道是不是看错了
为什么他们占的内存那么少但是,内存的使用量却一直蹭蹭的往上跑,对我就是要创这么多线程,用了ExecutorService定义了线程池了,然后要跑完我才通过shutdown和shutdownnow关闭掉线程池的,只是想测一下为什么设置了-Xmx这个参数为什么不起效果,所以疯狂建了这么多线程
围观
来自美丽的 NutzCN
添加回复
请先登陆