当前位置:网站首页>为什么会没有内存了呢
为什么会没有内存了呢
2022-08-11 07:25:00 【学习微站】
为什么会没有内存了呢?原因不外乎有两点:
1)分配的少了:比如虚拟机本身可使用的内存(一般通过启动时的VM参数指定)太少。
2)应用用的太多,并且用完没释放,浪费了。此时就会造成内存泄露或者内存溢出。
内存泄露:申请使用完的内存没有释放,导致虚拟机不能再次使用该内存,此时这段内存就泄露了,因为申请者不用了,而又不能被虚拟机分配给别人用。
内存溢出:申请的内存超出了JVM能提供的内存大小,此时称之为溢出。
1、当发生OOM时,服务已基本不可用,并且会出现以下明显报错信息。
2.JVM启动参数设置 -XX:+HeapDumpOnOutOfMemoryError 当发生OOM时自动输出堆的内存快照
-XX:HeapDumpPath=/tmp 输出目录将dump文件java_pid1.hprof拷到本地如果忘记设置启动参数,也可以通过命令行获取dump文件使用JDK自带的jmap命令:jmap -dump:format=b,file=heap.bin
3、本地先安装eclipse, 再安装MAT(Memory Analyzer Tool)工具,使用mat工具打开java_pid1.hprof文件,根据mat可以快速定位问题
预防
1、根据业务合理设置java内存大小,以及不定时查看业务运行时内存使用情况, 及时调整内存大小。
2、在写代码时,应该有意识避免写查询大对象sql。
3、针对循环业务要有意识避免内存不能释放进而导致OOM。
边栏推荐
- 【Pytorch】nn.ReLU(inplace=True)
- Test cases are hard?Just have a hand
- Redis source code: how to view the Redis source code, the order of viewing the Redis source code, the sequence of the source code from the external data structure of Redis to the internal data structu
- 关于Excel实现分组求和最全文档
- TF中使用softmax函数;
- There may be fields that cannot be serialized in the abnormal object of cdc and sqlserver. Is there anyone who can understand it? Help me to answer
- leetcode:69. x 的平方根
- The softmax function is used in TF;
- tf.reduce_mean() and tf.reduce_sum()
- 1046 划拳 (15 分)
猜你喜欢
记录一些遇见的bug——Lombok和Mapstruct的冲突导致,A component required a bean of type ‘com.XXX.controller.converter.
查询跟踪快递单号物流,智能分析物流中转有延误的单号
1091 N-自守数 (15 分)
1056 组合数的和 (15 分)
软件测试常用工具的用途及优缺点比较(详细)
Serverless + domain name can also build a personal blog? Really, and soon
接口测试的基础流程和用例设计方法你知道吗?
About # SQL problem: how to set the following data by commas into multiple lines, in the form of column display
Interaction of Pico neo3 in Unity
tf.cast(), reduce_min(), reduce_max()
随机推荐
[Recommender System]: Overview of Collaborative Filtering and Content-Based Filtering
JRS303-Data Verification
XXL-JOB 分布式任务调度中心搭建
1056 Sum of Combinations (15 points)
redis操作
【LeetCode每日一题】——682.棒球比赛
One-hot in TF
oracle19c不支持实时同步参数,请教一下大佬们有什么好的解决办法吗?
Conditional statements in TF; where()
matplotlib
About # SQL problem: how to set the following data by commas into multiple lines, in the form of column display
Find the latest staff salary and the last staff salary changes
break pad源码编译--参考大佬博客的总结
oracle19c does not support real-time synchronization parameters, do you guys have any good solutions?
详述 MIMIC护理人员信息表(十五)
Activity的四种启动模式
Pico neo3 Unity打包设置
Pytorch模型转ONNX模型
【Pytorch】nn.Linear,nn.Conv
2.1 - Gradient Descent