当前位置:首页 » 操作系统 » 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 03:11:55 浏览:85
企业内网搭建电影服务器侵权吗 发布:2024-10-09 03:07:14 浏览:105
python读取jpg 发布:2024-10-09 02:50:22 浏览:154
王者荣耀的服务器ip在哪 发布:2024-10-09 02:44:48 浏览:77
安卓怎么下载李宁 发布:2024-10-09 02:31:37 浏览:343
配置不高pr哪个版本最好用 发布:2024-10-09 01:57:15 浏览:789
编译OpenWrtipv6 发布:2024-10-09 01:51:40 浏览:124
python写入字节 发布:2024-10-09 01:24:22 浏览:648
如何设置超高难度密码 发布:2024-10-09 01:19:05 浏览:178
linux只读文件修改 发布:2024-10-09 01:13:08 浏览:87