Java Performance Tuning - Weak Reference

本文探讨了Java中长期对象持有短期对象所导致的性能问题,并介绍了如何使用弱引用解决此类问题。此外,还解释了软引用的概念及其应用场景。

In the best practise of java performance tuning
We always heard about that: The long term object hold a short term object is one of the most likely way to lead to performace issue.

What is that supposed to mean? It absolutely doesn't make any sence, So let's get it more concrete.

Let's say In a service class. There is a global Map,  which hold the user's order entry. The Entry is a transient object which reserve only for a short time. But when the global map fill the Entry, It's exist as long as the global Map. With time, the global map become bulky coz some many short term object has not been collected which are meant to collected!! 

So in this case, the weak reference come to rescue.

The Entry set in the global Map is a weak reference. If Entry Object is only reference by the weak reference ,then the entry will be the candidate for gc.

For details on

http://www-128.ibm.com/developerworks/java/library/j-jtp11225/     Give a brief introduction with Weak reference.

http://java.sun.com/developer/technicalArticles/ALT/RefObj/              Official iintroduction to Reference Object from Sun.

What is soft reference?
If the only remaining references to an object are weak or soft references, then that object is said to be softly reachable. The garbage collector does not aggressively collect softly reachable objects the way it does with weakly reachable ones -- instead it only collects softly reachable objects if it really "needs" the memory. Soft references are a way of saying to the garbage collector, "As long as memory isn't too tight, I'd like to keep this object around. But if memory gets really tight, go ahead and collect it and I'll deal with that." The garbage collector is required to clear all soft references before it can throw OutOfMemoryError.

More details about soft reference. Please refer
http://www.ibm.com/developerworks/java/library/j-jtp01246.html?S_TACT=105AGX02&S_CMP=EDU

 

内容概要:本文围绕VMware虚拟化环境在毕业设计中的应用,重点探讨其在网络安全与AI模型训练两大领域的实践价值。通过搭建高度隔离、可复现的虚拟化环境,解决传统物理机实验中存在的环境配置复杂、攻击场景难还原、GPU资源难以高效利用等问题。文章详细介绍了嵌套虚拟化、GPU直通(passthrough)、虚拟防火墙等核心技术,并结合具体场景提供实战操作流程与代码示例,包括SQL注入攻防实验中基于vSwitch端口镜像的流量捕获,以及PyTorch分布式训练中通过GPU直通实现接近物理机性能的模型训练效果。同时展望了智能化实验编排、边缘虚拟化和绿色计算等未来发展方向。; 适合人群:计算机相关专业本科高年级学生或研究生,具备一定虚拟化基础、网络安全或人工智能背景,正在进行或计划开展相关方向毕业设计的研究者;; 使用场景及目标:①构建可控的网络安全实验环境,实现攻击流量精准捕获与WAF防护验证;②在虚拟机中高效开展AI模型训练,充分利用GPU资源并评估性能损耗;③掌握VMware ESXi命令行与vSphere平台协同配置的关键技能; 阅读建议:建议读者结合VMware实验平台动手实践文中提供的esxcli命令与网络拓扑配置,重点关注GPU直通的硬件前提条件与端口镜像的混杂模式设置,同时可延伸探索自动化脚本编写与能效优化策略。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值