linux启动springboot项目出现java.lang.OutOfmemoryError: PermGen Space

由于用的个人的linux服务器,配置是1核2G的内存,然后个人搭建环境跑的公司的项目。

项目能正常启动,但是在输入网址,进行项目访问的时候,总是报ava.lang.OutOfmemoryError: PermGen Space内存溢出的异常

网上查要修改tomcat的配置,来将运行时候的内存减小,达到不会报错的目的。

但由于是spring boot 项目,是内置的tomcat,没有地方去修改tomcat的配置(个人理解,如果不对望大家指出,谢谢)

最后找到一篇非常好的博客,解决了问题。

https://blog.csdn.net/rickiyeat/article/details/78343362

 

在使用java -jar  启动的时候 

-Xms1024m -Xmx1024m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m

将运行时的内存提前定义好,这样就达到修改内置tomcat运行时内存的目的。

nohup java  -Xms1024m -Xmx1024m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m -jar xxxx.jar > /dev/null 2>&1 &

最后我们查一下内存使用情况

jmap -heap pid(ps -ef|grep java查看启动项目的pid是什么)

Attaching to process ID 14824, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.80-b11

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 536870912 (512.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 134217728 (128.0MB)
   MaxPermSize      = 268435456 (256.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 161021952 (153.5625MB)
   used     = 149734416 (142.79786682128906MB)
   free     = 11287536 (10.764633178710938MB)
   92.9900638640873% used
Eden Space:
   capacity = 143130624 (136.5MB)
   used     = 143113880 (136.4840316772461MB)
   free     = 16744 (0.01596832275390625MB)
   99.98830159505208% used
From Space:
   capacity = 17891328 (17.0625MB)
   used     = 6620536 (6.313835144042969MB)
   free     = 11270792 (10.748664855957031MB)
   37.00416201636905% used
To Space:
   capacity = 17891328 (17.0625MB)
   used     = 0 (0.0MB)
   free     = 17891328 (17.0625MB)
   0.0% used
tenured generation:
   capacity = 357957632 (341.375MB)
   used     = 71209248 (67.91043090820312MB)
   free     = 286748384 (273.4645690917969MB)
   19.893205685303002% used
Perm Generation:
   capacity = 134217728 (128.0MB)
   used     = 99136528 (94.54396057128906MB)
   free     = 35081200 (33.45603942871094MB)
   73.86246919631958% used

在最后能看出 内存占用率   Perm Generation:

73.86246919631958% used。

到这里能正常的运行和操作项目了。

你可能感兴趣的:(springboot,linux,服务器)