<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Java的内存泄漏</title>
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))'/>
<link rel="schema.DC" href="http://purl.org/DC/elements/1.0/"/>
<link rel="SHORTCUT ICON" href="http://www.ibm.com/favicon.ico"/>
<meta name="Owner" content="dw@cn.ibm.com"/>
<meta name="DC.Language" scheme="rfc1766" content="zh-CN"/>
<meta name="IBM.Country" content="CN"/>
<meta name="Security" content="Public"/>
<meta name="IBM.SpecialPurpose" content="SP001"/>
<meta name="IBM.PageAttributes" content="sid=1003,1004"/>
<meta name="Source" content="v16 Template Generator"/>
<meta name="Robots" content="index,follow"/>
<meta name="Abstract" content="Java的一个重要优点就是通过垃圾收集器(Garbage Collection,GC)自动管理内存的回收,程序员不需要通过调用函数来释放内存。因此,很多程序员认为Java不存在内存泄漏问题,或者认为即使有内存泄漏也不是程序的责任,而是GC或JVM的问题。其实,这种想法是不正确的,因为Java也存在内存泄露,但它的表现与C++不同。"/>
<meta name="Description" content="Java的一个重要优点就是通过垃圾收集器(Garbage Collection,GC)自动管理内存的回收,程序员不需要通过调用函数来释放内存。因此,很多程序员认为Java不存在内存泄漏问题,或者认为即使有内存泄漏也不是程序的责任,而是GC或JVM的问题。其实,这种想法是不正确的,因为Java也存在内存泄露,但它的表现与C++不同。"/>
<meta name="Keywords" content="Java, 内存泄漏, 垃圾收集器, Garbage Collection, GC, tttjca"/>
<meta name="DC.Date" scheme="iso8601" content="2002-10-21"/>
<meta name="DC.Type" scheme="IBM_ContentClassTaxonomy" content="CT316"/>
<meta name="DC.Subject" scheme="IBM_SubjectTaxonomy" content="TT300"/>
<meta scheme="IBM_WTMCategory" name="IBM.WTMCategory" content="SOFDCJVACN" />
<meta name="DC.Rights" content="© Copyright IBM Corporation 2002"/>
<meta name="IBM.Effective" scheme="W3CDTF" content="2002-10-21"/>
<meta name="title" content="Java的内存泄漏"/>
<!-- HEADER_SCRIPTS_AND_CSS_INCLUDE -->
<link href="//dw1.s81c.com/common/v16/css/all.css" media="all" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/common/v16/css/screen.css" media="screen,projection" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/common/v16/css/screen-uas.css" media="screen,projection" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/common/v16/css/cn/zh/screen-fonts.css" media="screen,projection" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/common/v16/css/handheld.css" media="handheld" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/common/v16/css/print.css" media="print" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/common/v16/css/overlay.css" media="screen,projection" rel="stylesheet" title="www" type="text/css"/>
<!-- dW-specific CSS -->
<link href="//dw1.s81c.com/developerworks/css/dw-screen.css" media="screen,projection" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/developerworks/css/dw-local-site.css" media="screen,projection" rel="stylesheet" title="www" type="text/css"/>
<link href="//dw1.s81c.com/developerworks/js/jquery/cluetip98/jquery.cluetip.css" media="screen,projection" rel="stylesheet" title="www" type="text/css" />
<link href="//dw1.s81c.com/developerworks/css/dw-mf/dw-mf0311.css" rel="stylesheet" title="www" type="text/css"/>
<script src="//dw1.s81c.com/common/js/ibmcommon.js" type="text/javascript">//</script>
<script src="//dw1.s81c.com/common/js/dynamicnav.js" type="text/javascript">//</script>
<!-- dW functional JS -->
<script language="JavaScript" src="//dw1.s81c.com/developerworks/js/urltactic.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
// <![CDATA[
dwr = {};
dwr.clickhere = '点击评分';
dwr.stars = '星';
dwr.star = '星';
dwr.avgRatingOf = '平均分';
dwr.youRated = '您的评分是';
dwr.avgRating = '平均分';
dwr.basedOnVote = '共 {1} 个评分'; // {1} to be substitue by code
dwr.basedOnVotes = '共 {1} 个评分';
dwr.leftParen = '(';
dwr.rightParen = ' )';
dwr.space = ' ';
dwr.yourRating = '您的评分';
// ]]>
</script>
<script language="JavaScript" src="//dw1.s81c.com/developerworks/js/artrating/artrating.js" type="text/javascript"></script>
<style type="text/css">
.metavalue {
display: none;
}
</style>
<!-- Rating_END --><!-- RESERVED_HEADER_INCLUDE -->
<script language="javascript" src="//dw1.s81c.com/developerworks/js/ajax1.js" type="text/javascript"></script>
<script language="javascript" src="//dw1.s81c.com/developerworks/js/search_counter-maverick.js" type="text/javascript"></script>
<script language="javascript" src="//dw1.s81c.com/developerworks/js/request_referer_capture-maverick.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
setDefaultQuery('defaultHere');
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
function openNewWindow(url,tar,arg){window.open(url,tar,arg);}
//-->
</script>
<!-- Include file support -->
<script language="JavaScript" type="text/javascript">
(function($) {
jQuery.extend({
getInc: function(u,d){
if(u==null)return;
jQuery.ajax({
type: "GET",
url: u,
dataType: "text",
success: function(t) {
jQuery(d).html(t);
ibmCommon.initShowHide(jQuery(d).children()[0]);
},
async: true
});
}
});
})(jQuery);
</script>
</head>
<body id="ibm-com">
<div id="ibm-top" class="ibm-landing-page">
<!-- MASTHEAD_BEGIN -->
<!-- MASTHEAD_BEGIN -->
<div class="ibm-access"><a href="#ibm-content">跳转到主要内容</a></div>
<div id="ibm-masthead-dw">
<!-- TOP ROW -->
<div id="dw-masthead-top-row">
<ul id="ibm-unav-home-dw">
<li id="ibm-logo">
<a href="http://www.ibm.com/cn/zh/"><img src="//dw1.s81c.com/developerworks/i/mf/ibm-smlogo.gif" width="44" height="16" alt="IBM®" /></a>
</li>
</ul>
<ul id="ibm-mast-options-dw" class="cn">
<li id="dw-mast-top-0">
<a class="dw-mf-noscript" href="#" title="Sign in (or register) requires JavaScript">登录 (或注册)</a>
</li>
<li id="dw-mast-top-1" class="dw-mast-top-1-cn">
<a href="#SELECTLANG">中文</a><img class="dw-preload" src="//dw1.s81c.com/developerworks/i/mf/arrow-down-active.gif" width="8" height="7" alt="" />
</li>
<li id="dw-mast-top-2" class="dw-mf-hide">
<a href="#">[userid]<img src="/developerworks/mydeveloperworks/profiles/photo.do?userid=[uid]" alt="PHOTO" class="dw-mast-profimg" width="20" height="20"/></a>
</li>
</ul>
</div>
<!-- TOP ROW SLIDER -->
<div id="ibm-my-menu-dw">
<div class="ibm-ribbon-pane-dw">
<div class="ibm-ribbon-section-dw">
<!-- Sign-in -->
<div class="dw-mast-columns">
<div class="dw-mast-col-1-1">
<div class="dw-mast-close">
<ul>
<li><a href="#">关闭 [x]</a></li>
</ul>
</div>
<div id="dw-mast-sso">
<div id="dw-mast-sso-reg">
<p class="dw-mast-sso-reg-cn">如果您还没有注册