當前位置:首頁 » 操作系統 » jvmlinux

jvmlinux

發布時間: 2022-05-10 21:02:58

㈠ 如何查看當前linux系統給JVM分配了多大的內存

以WAS為例:

[tmp]$ ps -ef | grep java
root 9787 1 0 Sep17 ? 00:02:48 /opt/IBM/WebSphere/AppServer/java/bin/java -Xms50m -Xmx256m

-Xms 和 -Xmx 分別代表分配JVM的最小內存和最大內存。

堆棧信息你可以用 kill -3 後面跟上java進程的pid,這樣就能生成 thread mp 了。

具體如下:

1、簡介C語言是一門通用計算機編程語言,應用廣泛。C語言的設計目標是提供一種能以簡易的方式編譯、處理低級存儲器、產生少量的機器碼以及不需要任何運行環境支持便能運行的編程語言。盡管C語言提供了許多低級處理的功能,但仍然保持著良好跨平台的特性,以一個標准規格寫出的C語言程序可在許多電腦平台上進行編譯,甚至包含一些嵌入式處理器(單片機或稱MCU)以及超級電腦等作業平台。

2、基本介紹

C語言,是一種通用的、過程式的編程語言,廣泛用於系統與應用軟體的開發。具有高效、靈活、功能豐富、表達力強和較高的移植性等特點,在程序員中備受青睞。最近25年是使用最為廣泛的編程語言。

3、運算

C語言的運算非常靈活,功能十分豐富,運算種類遠多於其它程序設計語言。在表達式方面較其它程序語言更為簡潔,如自加、自減、逗號運算和三目運算使表達式更為簡單,但初學者往往會覺的這種表達式難讀,關鍵原因就是對運算符和運算順序理解不透不全。當多種不同運算組成一個運算表達式,即一個運算式中出現多種運算符時,運算的優先順序和結合規則顯得十分重要。在學習中,對此合理進行分類,找出它們與數學中所學到運算之間的不同點之後,記住這些運算也就不困難了,有些運算符在理解後更會牢記心中,將來用起來得心應手,而有些可暫時放棄不記,等用到時再記不遲。

㈡ linux怎麼給jvm設置

最大值約為機器內存的一半。

㈢ 怎麼用linux命令查看jvm進程有幾個線程

在LINUX上可以使用kill -3 pid > thread.info來取得當前JVM線程的信息;
jstack 這個是用來查看jvm當前的thread mp的。可以看到當前Jvm裡面的線程狀況。
這個對於查找blocked線程比較有意義;

㈣ 我是小白,不懂JAVA!為什麼在linux 里設置JVM參數總是報錯

可以參考一下,Linux系統下手動設置jvm參數。

典型JVM參數設置:
java -Xmx3550m -Xms3550m -Xmn2g -Xss128k
-Xmx3550m:設置JVM最大可用內存為3550M。
-Xms3550m:設置JVM促使內存為3550m。此值可以設置與-Xmx相同,以避免每次垃圾回收完成後JVM重新分配內存。
-Xmn2g:設置年輕代大小為2G。整個堆大小=年輕代大小 + 年老代大小 + 持久代大小。持久代一般固定大小為64m,所以增大年輕代後,將會減小年老代大小。此值對系統性能影響較大,Sun官方推薦配置為整個堆的3/8。
-Xss128k:設置每個線程的堆棧大小。JDK5.0以後每個線程堆棧大小為1M,以前每個線程堆棧大小為256K。更具應用的線程所需內存大小進行調整。在相同物理內存下,減小這個值能生成更多的線程。但是操作系統對一個進程內的線程數還是有限制的,不能無限生成,經驗值在3000~5000左右。
java -Xmx3550m -Xms3550m -Xss128k -XX:NewRatio=4 -XX:SurvivorRatio=4 -XX:MaxPermSize=16m -XX:MaxTenuringThreshold=0
-XX:NewRatio=4:設置年輕代(包括Eden和兩個Survivor區)與年老代的比值(除去持久代)。設置為4,則年輕代與年老代所佔比值為1:4,年輕代占整個堆棧的1/5
-XX:SurvivorRatio=4:設置年輕代中Eden區與Survivor區的大小比值。設置為4,則兩個Survivor區與一個Eden區的比值為2:4,一個Survivor區占整個年輕代的1/6
-XX:MaxPermSize=16m:設置持久代大小為16m。

㈤ Linux裡面JVM內存怎麼設置

jar包啟動時指定對應參數,比如我的工程啟動命令就是這樣的

啟動命令,打碼部分為工程名

常見參數如下

1.-Xms:初始堆大小。只要啟動,就佔用的堆大小。

2.-Xmx:最大堆大小。java.lang.OutOfMemoryError:Java heap這個錯誤可以通過配置-Xms和-Xmx參數來設置。

3.-Xss:棧大小分配。棧是每個線程私有的區域,通常只有幾百K大小,決定了函數調用的深度,而局部變數、參數都分配到棧上。

當出現大量局部變數,遞歸時,會發生棧空間OOM(java.lang.StackOverflowError)之類的錯誤。

4.XX:NewSize:設置新生代大小的絕對值。

5.-XX:NewRatio:設置年輕代和年老代的比值。比如設置為3,則新生代:老年代=1:3,新生代占總heap的1/4。

6.-XX:MaxPermSize:設置持久代大小。

java.lang.OutOfMemoryError:PermGenspace這個OOM錯誤需要合理調大PermSize和MaxPermSize大小。

7.-XX:SurvivorRatio:年輕代中Eden區與兩個Survivor區的比值。注意,Survivor區有form和to兩個。比如設置為8時,那麼eden:form:to=8:1:1。

8.-XX:HeapDumpOnOutOfMemoryError:發生OOM時轉儲堆到文件,這是一個非常好的診斷方法。

9.-XX:HeapDumpPath:導出堆的轉儲文件路徑。

10.-XX:OnOutOfMemoryError:OOM時,執行一個腳本,比如發送郵件報警,重啟程序。後面跟著一個腳本的路徑。

㈥ 在linux中怎麼安裝jvm

Linux安裝JDK步驟1. 先從網上下載jdk(jdk-1_5_0_02-linux-i586.rpm)
,推薦SUN的官方網站www.sun.com,下載後放在/home目錄中,當然其它地方也行。

進入安裝目錄

#cd /home

#cp jdk-1_5_0_02-linux-i586.rpm /usr/local

#cd /usr/local

給所有用戶添加可執行的許可權

#chmod +x jdk-1_5_0_02-linux-i586.rpm.bin

#./jdk-1_5_0_02-linux-i586.rpm.bin

此時會生成文件jdk-1_5_0_02-linux-i586.rpm,同樣給所有用戶添加可執行的許可權

#chmod +x jdk-1_5_0_02-linux-i586.rpm

安裝程序

#rpm -ivh jdk-1_5_0_02-linux-i586.rpm

出現安裝協議等,按接受即可。

Linux安裝JDK步驟2.設置環境變數。

#vi /etc/profile

在最後面加入

#set java environment

JAVA_HOME=/usr/java/jdk-1_5_0_02

CLASSPATH=.:$JAVA_HOME/lib.tools.jar

PATH=$JAVA_HOME/bin:$PATH

export JAVA_HOME CLASSPATH PATH

保存退出。

要使JDK在所有的用戶中使用,可以這樣:

vi /etc/profile.d/java.sh

在新的java.sh中輸入以下內容:

#set java environment

JAVA_HOME=/usr/java/jdk-1_5_0_02

CLASSPATH=.:$JAVA_HOME/lib/tools.jar

PATH=$JAVA_HOME/bin:$PATH

export JAVA_HOME CLASSPATH PATH

保存退出,然後給java.sh分配許可權:chmod 755 /etc/profile.d/java.sh

Linux安裝JDK步驟3.在終端使用echo命令檢查環境變數設置情況。

#echo $JAVA_HOME

#echo $CLASSPATH

#echo $PATH

4.檢查JDK是否安裝成功。

#java -version

如果看到JVM版本及相關信息,即安裝成功!

㈦ JVM在linux中佔用的虛擬內存為什麼這么高

This has been a long-standing complaint with Java, but it's largely meaningless, and usually based on looking at the wrong information. The usual phrasing is something like "Hello World on Java takes 10 megabytes! Why does it need that?" Well, here's a way to make Hello World on a 64-bit JVM claim to take over 4 gigabytes ... at least by one form of measurement.
java -Xms1024m -Xmx4096m com.example.Hello

Different Ways to Measure Memory
On Linux, the top command gives you several different numbers for memory. Here's what it says about the Hello World example:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2120 kgregory 20 0 4373m 15m 7152 S 0 0.2 0:00.10 java

VIRT is the virtual memory space: the sum of everything in the virtual memory map (see below). It is largely meaningless, except when it isn't (see below).
RES is the resident set size: the number of pages that are currently resident in RAM. In almost all cases, this is the only number that you should use when saying "too big." But it's still not a very good number, especially when talking about Java.
SHR is the amount of resident memory that is shared with other processes. For a Java process, this is typically limited to shared libraries and memory-mapped JARfiles. In this example, I only had one Java process running, so I suspect that the 7k is a result of libraries used by the OS.
SWAP isn't turned on by default, and isn't shown here. It indicates the amount of virtual memory that is currently resident on disk, whether or not it's actually in the swap space. The OS is very good about keeping active pages in RAM, and the only cures for swapping are (1) buy more memory, or (2) rece the number of processes, so it's best to ignore this number.
The situation for Windows Task Manager is a bit more complicated. Under Windows XP, there are "Memory Usage" and "Virtual Memory Size" columns, but the official documentation is silent on what they mean. Windows Vista and Windows 7 add more columns, and they're actually documented. Of these, the "Working Set" measurement is the most useful; it roughly corresponds to the sum of RES and SHR on Linux.
Understanding the Virtual Memory Map
The virtual memory consumed by a process is the total of everything that's in the process memory map. This includes data (eg, the Java heap), but also all of the shared libraries and memory-mapped files used by the program. On Linux, you can use the pmap command to see all of the things mapped into the process space (from here on out I'm only going to refer to Linux, because it's what I use; I'm sure there are equivalent tools for Windows). Here's an excerpt from the memory map of the "Hello World" program; the entire memory map is over 100 lines long, and it's not unusual to have a thousand-line list.
0000000040000000 36K r-x-- /usr/local/java/jdk-1.6-x64/bin/java
0000000040108000 8K rwx-- /usr/local/java/jdk-1.6-x64/bin/java
0000000040eba000 676K rwx-- [ anon ]
00000006fae00000 21248K rwx-- [ anon ]
00000006fc2c0000 62720K rwx-- [ anon ]
0000000700000000 699072K rwx-- [ anon ]
000000072aab0000 2097152K rwx-- [ anon ]
00000007aaab0000 349504K rwx-- [ anon ]
00000007c0000000 1048576K rwx-- [ anon ]
...
00007fa1ed00d000 1652K r-xs- /usr/local/java/jdk-1.6-x64/jre/lib/rt.jar
...
00007fa1ed1d3000 1024K rwx-- [ anon ]
00007fa1ed2d3000 4K ----- [ anon ]
00007fa1ed2d4000 1024K rwx-- [ anon ]
00007fa1ed3d4000 4K ----- [ anon ]
...
00007fa1f20d3000 164K r-x-- /usr/local/java/jdk-1.6-x64/jre/lib/amd64/libjava.so
00007fa1f20fc000 1020K ----- /usr/local/java/jdk-1.6-x64/jre/lib/amd64/libjava.so
00007fa1f21fb000 28K rwx-- /usr/local/java/jdk-1.6-x64/jre/lib/amd64/libjava.so
...
00007fa1f34aa000 1576K r-x-- /lib/x86_64-linux-gnu/libc-2.13.so
00007fa1f3634000 2044K ----- /lib/x86_64-linux-gnu/libc-2.13.so
00007fa1f3833000 16K r-x-- /lib/x86_64-linux-gnu/libc-2.13.so
00007fa1f3837000 4K rwx-- /lib/x86_64-linux-gnu/libc-2.13.so
...

A quick explanation of the format: each row starts with the virtual memory address of the segment. This is followed by the segment size, permissions, and the source of the segment. This last item is either a file or "anon", which indicates a block of memory allocated via mmap.
Starting from the top, we have
The JVM loader (ie, the program that gets run when you typejava). This is very small; all it does is load in the shared libraries where the real JVM code is stored.
A bunch of anon blocks holding the Java heap and internal data. This is a Sun JVM, so the heap is broken into multiple generations, each of which is its own memory block. Note that the JVM allocates virtual memory space based on the-Xmxvalue; this allows it to have a contiguous heap. The-Xmsvalue is used internally to say how much of the heap is "in use" when the program starts, and to trigger garbage collection as that limit is approached.
A memory-mapped JARfile, in this case the file that holds the "JDK classes." When you memory-map a JAR, you can access the files within it very efficiently (versus reading it from the start each time). The Sun JVM will memory-map all JARs on the classpath; if your application code needs to access a JAR, you can also memory-map it.
Per-thread data for two threads. The 1M block is a thread stack; I don't know what goes into the 4K block. For a real app, you will see dozens if not hundreds of these entries repeated through the memory map.
One of the shared libraries that holds the actual JVM code. There are several of these.
The shared library for the C standard library. This is just one of many things that the JVM loads that are not strictly part of Java.
The shared libraries are particularly interesting: each shared library has at least two segments: a read-only segment containing the library code, and a read-write segment that contains global per-process data for the library (I don't know what the segment with no permissions is; I've only seen it on x64 Linux). The read-only portion of the library can be shared between all processes that use the library; for example,libchas 1.5M of virtual memory space that can be shared.
When is Virtual Memory Size Important?
The virtual memory map contains a lot of stuff. Some of it is read-only, some of it is shared, and some of it is allocated but never touched (eg, almost all of the 4Gb of heap in this example). But the operating system is smart enough to only load what it needs, so the virtual memory size is largely irrelevant.
Where virtual memory size is important is if you're running on a 32-bit operating system, where you can only allocate 2Gb (or, in some cases, 3Gb) of process address space. In that case you're dealing with a scarce resource, and might have to make tradeoffs, such as recing your heap size in order to memory-map a large file or create lots of threads.
But, given that 64-bit machines are ubiquitous, I don't think it will be long before Virtual Memory Size is a completely irrelevant statistic.
When is Resident Set Size Important?
Resident Set size is that portion of the virtual memory space that is actually in RAM. If your RSS grows to be a significant portion of your total physical memory, it might be time to start worrying. If your RSS grows to take up all your physical memory, and your system starts swapping, it's well past time to start worrying.
But RSS is also misleading, especially on a lightly loaded machine. The operating system doesn't expend a lot of effort to reclaiming the pages used by a process. There's little benefit to be gained by doing so, and the potential for an expensive page fault if the process touches the page in the future. As a result, the RSS statistic may include lots of pages that aren't in active use.
Bottom Line
Unless you're swapping, don't get overly concerned about what the various memory statistics are telling you. With the caveat that an ever-growing RSS may indicate some sort of memory leak.
With a Java program, it's far more important to pay attention to what's happening in the heap. The total amount of space consumed is important, and there are some steps that you can take to rece that. More important is the amount of time that you spend in garbage collection, and which parts of the heap are getting collected.
Accessing the disk (ie, a database) is expensive, and memory is cheap. If you can trade one for the other, do so.

㈧ linux下JVM的參數在哪裡設置

在文件 /etc/profile 最後加上一行

export JAVA_OPTIONS=-Xms512m -Xmx512m

㈨ 如何jvm監控linux伺服器

如何配置visualvm監控
visualvm支持在Linux和windows上啟用圖形界面監控jvm的資源,但是如何可以使我們在windows上監控到遠程linux伺服器資源,這還需要做一些配置,此文是在原文基礎上做了更改的,希望對大家能有所幫助。
(1)首先要修改JDK中JMX服務的配置文件,以獲得相應的許可權:
進入$JAVA_HOME所在的根目錄的/jre/lib/management子目錄下,
a. 將jmxremote.password.template文件復制為jmxremote.password
b. 調整jmxremote.access和jmxremote.password的許可權為只讀寫,可以使用如下命令
chmod 600 jmxremote.access jmxremote.password
c. 打開jmxremote.password文件,去掉
# monitorRole QED
# controlRole R&D
這兩行前面的注釋符號
(2)修改env.sh
打開env.sh文件,並在JVM的啟動配置中添加如下信息:
JAVA_OPTS="-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=10.20.150.218 其他配置」
這幾個配置的說明如下:
-Dcom.sun.management.jmxremote.port:這個是配置遠程connection的埠號的,要確定這個埠沒有被佔用
-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false:這兩個是固定配置,是JMX的遠程服務許可權的
-Djava.rmi.server.hostname:這個是配置server的IP的,要使用server的IP最好在機器上先用hostname –i看一下IP是不是機器本身的IP,如果是127.0.0.1的話要改一下,否則遠程的時候連不上,目前我們的server上我已經都改好了
(3)Windows客戶端配置
JDK 1.6版本自帶visualvm,只需要進到bin目錄下啟動即可
啟動後頁面比較簡潔,配置也很簡單:
a. 點擊左側菜單的add Remote host,輸入server的IP,然後再advanced settings里配置埠(注意這個埠要和server上的埠一致)
b. 右擊剛才配置的IP,選擇JMX connection方式,再次輸入埠,就可以監視到JVM資源了

㈩ linux中jvm內存不夠怎麼解決

加大JVM啟動時的內存 java -Xmx1g -Xms1g application -Xmx1g 設置最大可用內存為1g -Xms1g 設置內存初始化最小值1g

熱點內容
阿里雲怎麼領伺服器 發布:2024-10-09 05:17:53 瀏覽:816
c語言可逆素數 發布:2024-10-09 05:13:44 瀏覽:920
班級采訪問題 發布:2024-10-09 04:45:44 瀏覽:497
單人地圖腳本 發布:2024-10-09 04:45:32 瀏覽:754
易語言cf自瞄源碼 發布:2024-10-09 04:36:14 瀏覽:121
安卓和蘋果哪個更難修理 發布:2024-10-09 04:36:12 瀏覽:26
黎明覺醒安卓什麼配置 發布:2024-10-09 04:32:05 瀏覽:127
助手autojs腳本 發布:2024-10-09 04:31:40 瀏覽:186
sql判斷今天 發布:2024-10-09 04:19:35 瀏覽:943
拆分視頻需要哪些配置 發布:2024-10-09 04:06:39 瀏覽:912