- 浏览: 1509211 次
- 性别:
- 来自: 厦门
文章分类
- 全部博客 (516)
- Java (49)
- Java/Struts 2.0 (25)
- Java/Spring、Spring MVC (11)
- Java/Quartz (3)
- Java/Lucene (6)
- Java/Hibernate (19)
- Java/openJPA (7)
- Java/DWR (7)
- Java/Security、Spring Security/OAuth2 (6)
- Java/Threading (9)
- Java/XML (22)
- java/design pattern (4)
- Android (2)
- JavaScript (46)
- jquery (3)
- DB/MySQL (23)
- DB/Oracle (16)
- PHP (25)
- CSS (20)
- Linux (38)
- C/C++、DLL、Makefile、VC++ (31)
- 正则 (9)
- Eclipse (4)
- 安全、网络等概念 (25)
- 集群 (7)
- 网页 (5)
- 视频\音频 (1)
- HTML (6)
- 计算机数学/算法 (3)
- Virtualbox (1)
- LDAP (2)
- 数据挖掘 (6)
- 工具破解 (1)
- 其他 (13)
- Mail (1)
- 药材 (3)
- 游戏 (2)
- hadoop (13)
- 压力测试 (3)
- 设计模式 (3)
- java/Swing (2)
- 缓存/Memcache (0)
- 缓存/Redis (1)
- OSGI (2)
- OSGI/Gemini (0)
- 文档写作 (0)
- java/Servlet (3)
- MQ/RabbitMQ (2)
- MQ/RocketMQ (0)
- MQ/Kafka (1)
- maven (0)
- SYS/linux (1)
- cache/redis (1)
- DB/Mongodb (2)
- nginx (1)
- postman (1)
- 操作系统/ubuntu (1)
- golang (1)
- dubbo (1)
- 技术管理岗位 (0)
- mybatis-plus (0)
最新评论
-
pgx89112:
大神,请赐我一份这个示例的项目代码吧,万分感谢,1530259 ...
spring的rabbitmq配置 -
string2020:
不使用增强器 怎么弄?
OpenJPA的增强器 -
孟江波:
学习了,楼主,能否提供一份源代码啊,学习一下,十分感谢!!!4 ...
spring的rabbitmq配置 -
eachgray:
...
spring-data-redis配置事务 -
qljoeli:
学习了,楼主,能否提供一份源代码啊,学习一下,十分感谢!!!1 ...
spring的rabbitmq配置
http://blogs.opcodesolutions.com/roller/java/entry/solve_java_lang_outofmemoryerror_java
An OOM or OOME (OutOfMemoryError) simply means that the JVM ran out of memory. When this occurs, you basically have 2 choices:
- Allow the JVM to use more memory using the -Xmx VM argument. For instance, to allow the JVM to use 1 GB (1024 MB) of memory:
java -Xmx1024m ...
- Improve/Fix the application so that it uses less memory
In many cases, like in the case of a memory leak, the second option is the only sound choice. A memory leak happens when the application keeps more and more references to objects and never releases them. The garbage collector will therefore never collect those objects and less and less free memory will be available until we reach the point where not enough free memory is available for the application to function normally. At this point, the JVM will throw an OOM.
A memory leak can be very latent. For instance, the application might behave flawlessly during development and QA. However, it suddenly throws a OOM after several days in production at customer site. To solve that issue, you first need to find the root cause of it. The root cause can be very hard to find in development if it cannot be reproduced in-house. Here are the steps to follow in order to find the root cause and fix that issue:
- Start the application with the VM argument -XX:+HeapDumpOnOutOfMemoryError . This will tell the VM to produce a heap dump when a OOM occurs:
java -XX:+HeapDumpOnOutOfMemoryError ...
- Reproduce the problem. Well, if you cannot reproduce in dev, you will have to use the production environment.
- Use VisualVM to read the heap dump file and diagnose the issue.
First of all, a heap dump is the dump of the heap (duh!). It will allow you to navigate the heap and see what objects use all the heap memory and which are the ones that still keep a reference on them, and so on and so forth. This will give you very strong hints and you will (hopefully) be able to find the root cause of the problem. The problem could be a cache that grows indefinitely, a list that keeps collecting business-specific data in memory, a huge request that tries to load almost all data from database in memory, etc.
Once you know the root cause of the problem, you can elaborate solutions to fix it. In case of a cache that grows indefinitely, a good solution could be to set a reasonable limit to that cache. In case of a query that tries to load almost all data from database in memory, you may have to change the way you manipulate data; you could even have to change the behavior of some functionalities of the application.
If you do not want to wait for a OOM or if you just want to see what is in memory, you can still generate heap dump. To manually trigger a heap dump, you have 2 choices:
- Use VisualVM , right-click on the process on the left pane and select Heap Dump
- If you do not have a graphical environment and can't use vnc (VisualVM needs a graphical environment), use jps and jmap to generate the heap dump file. Then copy the file to your workstation and use VisualVM to read the heap dump (File -> Load...):
user@host:~$ jps
20198
21734 WordFinder
21921 Jps
21168 Main
user@host:~$ jmap -dump:live,format=b,file=heap.bin 21734
Dumping heap to /home/user/heap.bin ...
Heap dump file created
Here is what VisualVM looks with a heap dump:
Alternatively, you can also use jhat to read heap dumps.
发表评论
-
HttpRequestClient
2018-11-21 17:45 516http请求工具 public class WebCon ... -
Spring boot 环境下配置CKEditor添加google map
2017-07-05 14:39 1223本文档基于已经搭建好基础ckeditor的环境上。如:ht ... -
post json
2015-12-30 12:35 502方法一: public static String doP ... -
maven打包成可执行的jar包(package a runnable jar)
2015-04-23 22:01 2188第一步:利用maven-jar-plugin生成当前工程的 ... -
自定义ObjectMapper
2015-03-02 16:57 7716d import java.io.IOExcept ... -
JsonObjectMapper
2015-02-05 10:41 1366import com.fasterxml.jackson. ... -
HttpServletRequestWrapper
2014-10-12 08:15 565请求提交后替换HTML字符 import javax.s ... -
配置javamelody
2014-09-12 14:03 1235参考后面地址修改整理。http://my.oschina.n ... -
getTrace()
2014-08-06 09:14 535/** * 将e.printStackTrace() ... -
获取java对象在内存的地址
2014-07-28 14:59 2836引用stackflow的文章:http://stackove ... -
JMeter入门:Java Request实例
2014-05-08 15:41 2307转自:http://softtest.chin ... -
解决在IE下下载时文件名乱码
2014-01-09 11:24 1028String agent = request.getHead ... -
第一节:编译自定义的Hadoop核心包,去除用户权限检查
2013-11-30 11:59 1032本文参考eclipse连接远程hadoop集群开发时0700 ... -
第二节:win 7下编译eclispe hadoop plugin
2013-11-29 19:12 807本文参照后面地址的Linux编译方式:http: ... -
使用log4j为Tomcat输出日志
2013-11-01 16:42 10313转自:http://hi.baidu.com/y ... -
xStream开发HTTP的XML内容
2013-07-03 09:58 10281、编写自定义XPPDriver代码: package ... -
HttpURLConnection or URLConnection post xml content to web server
2013-05-31 01:56 2029客户端示例1: package client; ... -
java nio学习笔记
2013-03-21 21:41 0直接缓冲区被用于与通道和固有I/O例程交互。它们 ... -
Jsch使用
2012-12-10 17:07 2499Jsch shell模式下的代码示例: 参考: ... -
Exe4j破解_Exe4j注册码
2012-12-06 17:35 33516exe4j是个很好的打包利器,官方下载地址:http://ww ...
相关推荐
gcr.io/distroless/static:latest,制作k8s.gcr.io/metrics-server/metrics-server:v0.4.1的基础资源
This book shows you how to solve "callback hell" with RxJava and shows you how to write thread-safe code without hanging onto state variables which comes in handy for cloud computing software-as-a-...
It is also meant for those familiar with Apache Maven, but want to understand the finer nuances of Maven and solve specific problems. What You Will Learn Install Apache Maven successfully on your ...
本地启动jar包 ... Error: "RSA premaster secret error" 所以需要导入一个包: Solving the problem was a matter of putting the sunjce... Hard to find, easy to solve. 把sunjce_provider.jar 放到JDKclasspath路径下
Your robot will learn how to problem solve, how to plan, how to learn, and how to communicate. Along the way, you’ll learn about classical AI algorithms for teaching hardware how to think, ...
用粒子群算法求解车间调度问题,包含甘特图的制作程序
If you are a Java programmer who wants to learn about the fundamental tasks underlying natural ...solve more difficult problems Readers should be familiar experienced with Java software development ...
• How to solve an LP problem? • Where to go? LECTURE 2: PRELIMINARIES 1. Standard form LP 2. Embedded assumptions 3. Converting to standard form LECTURE 3: GEOMETRY OF LP 1. Terminologies 2. ...
Develop a sound strategy to solve predictive modelling problems using the most popular machine learning Java libraries. Explore a broad variety of data processing, machine learning, and natural ...
Create and unleash the power of neural networks by implementing professional Java code About This Book Learn to build amazing projects using neural networks including forecasting the weather and ...
Genetic Algorithms in Java Basics is a brief introduction to solving problems using genetic algorithms, with working projects and solutions written in the Java programming language. This brief book ...
you will learn the vocabulary necessary to solve real-world problems and how to present your content on the television through Android. In addition to practical code examples, you will learn about ...
Java 9 Data Structures and Algorithms covers classical, functional, and reactive data structures, giving you the ability to understand computational complexity, solve problems, and write efficient ...
Solve the lags problem. 7: Reboot. WIN 10 X64 Patch Instructions: 1: Install the software EPLAN series. 2: Copy the license file SN-U10066.EGF to folder C:\User\Public\Eplan\Common\ 3: Turn off ...
Explore various approaches to organize and extract useful text from unstructured data using Java About This Book Integrate basic tasks to tackle more complex NLP problems Train NLP models to address ...
Walking through example applications, you will learn the vocabulary necessary to solve real-world problems and how to present your content on the television through Android. In addition to practical ...
专门用于线性规划,应用语言为AMPL,编程后有多种解法可选择
Take your first step towards a career in software development with this introduction to Java, one of the most in-demand programming languages and the foundation of the Android. Designed for beginners,...
XPath-Solve.rar XPath-Solve.rar XPath-Solve.rar