【Eclipse】eclipse中設置tomcat啓動時候的JVM參數

主要經過如下的幾個jvm參數來設置堆內存的:
-Xmx512m     最大總堆內存,通常設置爲物理內存的1/4
-Xms512m     初始總堆內存,通常將它設置的和最大堆內存同樣大,這樣就不須要根據當前堆使用狀況而調整堆的大小了
-Xmn192m     年輕帶堆內存,sun官方推薦爲整個堆的3/8
堆內存的組成     總堆內存 = 年輕帶堆內存 + 年老帶堆內存 + 持久帶堆內存
年輕帶堆內存     對象剛建立出來時放在這裏
年老帶堆內存     對象在被真正會回收以前會先放在這裏
持久帶堆內存     class文件,元數據等放在這裏
-XX:PermSize=128m     持久帶堆的初始大小
-XX:MaxPermSize=128m     持久帶堆的最大大小,eclipse默認爲256m。若是要編譯jdk這種,必定要把這個設的很大,由於它的類太多了。

 



在tomcat上雙擊 ,點 open lunch configuration,在argument籤頁下,直接在VMargument後面追加設置 ,如 -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxNewSize=256M -XX:MaxPermSize=256M


例如:個人配置:
-Xms5200M -Xmx5200M -XX:PermSize=512M -XX:MaxPermSize=512M

 

利用JDK自導的jmap查看:(先用jps查看pid,而後個jmap查看內存)
jps  查出的三個pid
C:\Users\liqia>jps
520404 Bootstrap
575844 Jps
348088

 


經過任務管理器查看進程的ID能夠看到:


  也就是說帶Bootstrap的是Tomcat,348088是eclipse。

1.  查看JVM內存信息:(驗證剛纔的配置)

方法一:
C:\Users\liqia>jmap -heap 520404
Attaching to process ID 520404, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.80-b11

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 0
   MaxHeapFreeRatio = 100
   MaxHeapSize      = 5452595200 (5200.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 536870912 (512.0MB)
   MaxPermSize      = 536870912 (512.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 1363673088 (1300.5MB)
   used     = 1122021344 (1070.0429382324219MB)
   free     = 241651744 (230.45706176757812MB)
   82.27934934505359% used
From Space:
   capacity = 227016704 (216.5MB)
   used     = 172383432 (164.39765167236328MB)
   free     = 54633272 (52.10234832763672MB)
   75.93425019508696% used
To Space:
   capacity = 227016704 (216.5MB)
   used     = 0 (0.0MB)
   free     = 227016704 (216.5MB)
   0.0% used
PS Old Generation
   capacity = 3635412992 (3467.0MB)
   used     = 73744 (0.0703277587890625MB)
   free     = 3635339248 (3466.929672241211MB)
   0.0020284903025400204% used
PS Perm Generation
   capacity = 536870912 (512.0MB)
   used     = 58398232 (55.692893981933594MB)
   free     = 478472680 (456.3071060180664MB)
   10.877518355846405% used

 

方法二:利用tomcat的自帶項目查看:到tomcat主頁點擊server  status



方法三:用JDK自帶的jvisualvm.exe查看










2  查看pid爲348088的內存(驗證eclipse的配置)
eclipse.ini配置
-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300.v20150602-1417
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
1024M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms4096m
-Xmx4096m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-Xloggc:gc.log
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails

 

 jps命令查看內存信息:tomcat

C:\Users\liqia>jmap -heap 348088
Attaching to process ID 348088, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.80-b11

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 0
   MaxHeapFreeRatio = 100
   MaxHeapSize      = 4294967296 (4096.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 536870912 (512.0MB)
   MaxPermSize      = 536870912 (512.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 1145569280 (1092.5MB)
   used     = 202738320 (193.34632873535156MB)
   free     = 942830960 (899.1536712646484MB)
   17.697604460901744% used
From Space:
   capacity = 146800640 (140.0MB)
   used     = 46552800 (44.396209716796875MB)
   free     = 100247840 (95.60379028320312MB)
   31.711578369140625% used
To Space:
   capacity = 139460608 (133.0MB)
   used     = 0 (0.0MB)
   free     = 139460608 (133.0MB)
   0.0% used
PS Old Generation
   capacity = 2863661056 (2731.0MB)
   used     = 154200136 (147.05670928955078MB)
   free     = 2709460920 (2583.943290710449MB)
   5.384720222978791% used
PS Perm Generation
   capacity = 536870912 (512.0MB)
   used     = 153296424 (146.19486236572266MB)
   free     = 383574488 (365.80513763427734MB)
   28.553684055805206% used
相關文章
相關標籤/搜索