
今のところSafari3限定 (確認したのはバージョン 3.2.1 (5525.27.1))なのだが、IMGタグを追加したりremoveしまくってたりすると、どんどん使用メモリが増えてくる現象を発見した。
Safari4のβ版やらFirefoxではそういった事にならないのは確認したが、単純なDOM操作なのにもりもりメモリを使って行く。
ウインドウを閉じてもメモリは解放されずに、解放しなかったメモリは内部的に再利用してるっぽい。
で、閉じる前に確保してたメモリ領域を使い切ったっぽいポイントでまたメモリをもりもり食べ出す。
まるでメモリプールみたいな感じなんだがウインドウを閉じるまで再利用されてない感じなんだ。
ちなみにSRC属性を指定しないとメモリがもりもり増えなかったりする。
以下のHTMLをローカルに保存して、保存した所と同じディレクトリにdummy.pngという適当な画像を置いてからブラウザで開いて下さい。
メモリが増える様子はアクティビティモニタ等で見るとわかり易いでしょう。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>memory leak test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="content-script-type" content="text/javascript">
<script>
var count = 0;
var is_run = true;
var $ = function(id){
return document.getElementById(id);
};
var reload = function(){
var container = $("container");
while (container.childNodes.length > 0) {
container.removeChild(container.childNodes[0]);
}
add();
};
function add(){
$("count").innerHTML = count++;
var i;
for (i = 0; i < 100 ; i++) {
var img = document.createElement('img');
img.src = "dummy.png";
$("container").appendChild(img);
}
if (is_run) setTimeout(reload, 100);
}
window.onload = function(){
$("reload").addEventListener("click", reload, false);
$("stop").addEventListener("click", function(){
is_run = false;
}, false);
add();
};
</script>
</head><body>
<div id="stop">stop</div>
<div id="reload">reload</div>
<div id="count">0</div>
<div id="container"></div>
</body></html>
きっとamachangなら理由わかってそうだなー。という気はしてる。
leaksコマンドと言う便利コマンドがあるので、実行したりウインドウ閉じたり開いたりした時の結果もはっときます。
なんか色々leakしてるけど、今回と関係あるかどうかはわからない。
$ leaks 7011 Process 7011: 199039 nodes malloced for 19823 KB Process 7011: 0 leaks for 0 total leaked bytes.
$ leaks 7011 Process 7011: 305529 nodes malloced for 30869 KB Process 7011: 0 leaks for 0 total leaked bytes.
$ leaks 7011 Process 7011: 1067031 nodes malloced for 107063 KB Process 7011: 0 leaks for 0 total leaked bytes.アクティビティモニタのRSIZEももりもり増える
$ leaks 7011 Process 7011: 205175 nodes malloced for 20180 KB Process 7011: 1 leak for 16 total leaked bytes. Leak: 0x1ca2dbc0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x15015080 0x00000004 0x00000000 ..[..P..........mallocedのサイズが減ってるけどRSIZは変わらず。そして1個リーク。
$ leaks 7011 Process 7011: 205273 nodes malloced for 20262 KB Process 7011: 4 leaks for 64 total leaked bytes. Leak: 0x16c0d300 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x02015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca2dbc0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x15015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca376a0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x01015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1cae0120 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x03015080 0x00000004 0x00000000 ..[..P..........RSIZEかわらず。3個リーク増えた。
$ leaks 7011 Process 7011: 269750 nodes malloced for 26522 KB Process 7011: 4 leaks for 64 total leaked bytes. Leak: 0x16c0d300 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x02015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca2dbc0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x15015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca376a0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x01015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1cae0120 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x03015080 0x00000004 0x00000000 ..[..P..........
$ leaks 7011 Process 7011: 1354957 nodes malloced for 131749 KB Process 7011: 4 leaks for 64 total leaked bytes. Leak: 0x16c0d300 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x02015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca2dbc0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x15015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca376a0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x01015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1cae0120 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x03015080 0x00000004 0x00000000 ..[..P..........
$ leaks 7011 Process 7011: 209735 nodes malloced for 20861 KB Process 7011: 5 leaks for 80 total leaked bytes. Leak: 0x16c0d300 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x02015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca2dbc0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x15015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1ca376a0 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x01015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1cadd650 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x0b015080 0x00000004 0x00000000 ..[..P.......... Leak: 0x1cae0120 size=16 instance of 'TSMInputSource', type CFType, implemented in HIToolbox 0xa05bcee0 0x03015080 0x00000004 0x00000000 ..[..P..........リーク増えた Posted by Yappo at 2009年04月02日 21:04 | TrackBack | tech
TradeTang is the premiere online china wholesale distributor and closeout company helping small businesses and entrepreneurs compete against larger enterprises. We sell bulk wholesale merchandise at the best prices around. TradeTang offers cheap products with high quality at wholesale prices. Our products are sold by the single case or you can buy in bulk. As a wholesale supplier, we pride ourselves on being able to bring business owners high-quality wholesale items at low prices.
We provide popular wholesale products such as Racing Parts,Tools ,Accessories Parts and Cell Phones ,Other. Well begun is the half done. Please choose our platform to shorten your way to the success.
The power supply manufacturer, Best Power Supply Manufacturer,we are a temperature sensor manufacturer. ... capsule filling machine manufacturers, sheet metal fabrication, air compressor, you have come to the right place. To see all the air compressor We can offer a complete program of products,ranging from metallic yarn,metallic yarn Packing.Metlon produces their metallic Zeatin trans-zeatin Zeatin-riboside trans-zeatin-riboside PVC pipe fittings packing machine manufacturer. packing machine manufacturer in china, Auto OEM Manufacturer of switching power supply,Switching Power Supply Design and power inverter provider,
buy replica bags come here, our site have good replica handbags and Louis Vuitton replica ,find good replica louis vuitton handbag and replica handbag or replica handbag .please contact us .Replica Jewelry.replica bagReplica Louis Vuitton .Replica Louis Vuitton handbag we are the best choose
rs gold | RS money | buy rs money | buy rs gold | cheap rs gold | cheap rs money | Runescape gold | Runescape money | Runescape power leveling | Runescape powerleveling | rs power leveling | rs powerleveling | rs accounts | rs account | runescape accounts | runescape account | rs powerleveling | Runescape powerleveling | rs power leveling | Runescape power leveling | Runescape gold|Runescape Money | Runescape gold|Runescape Money | rs gold|rs Moneyrs gold | RS money | buy rs money | buy rs gold | cheap rs gold | cheap rs money | Runescape gold | Runescape money | Runescape power leveling | Runescape powerleveling | rs power leveling | rs powerleveling | rs accounts | rs account | runescape accounts | runescape account | rs powerleveling | Runescape powerleveling | rs power leveling | Runescape power leveling | Runescape gold|Runescape Money | Runescape gold|Runescape Money | rs gold|rs Moneyrs gold | RS money | buy rs money | buy rs gold | cheap rs gold | cheap rs money | Runescape gold | Runescape money | Runescape power leveling | Runescape powerleveling | rs power leveling | rs powerleveling | rs accounts | rs account | runescape accounts | runescape account | rs powerleveling | Runescape powerleveling | rs power leveling | Runescape power leveling | Runescape gold|Runescape Money | Runescape gold|Runescape Money | rs gold|rs Moneyrs gold | RS money | buy rs money | buy rs gold | cheap rs gold | cheap rs money | Runescape gold | Runescape money | Runescape power leveling | Runescape powerleveling | rs power leveling | rs powerleveling | rs accounts | rs account | runescape accounts | runescape account | rs powerleveling | Runescape powerleveling | rs power leveling | Runescape power leveling | Runescape gold|Runescape Money | Runescape gold|Runescape Money | rs gold|rs Moneyrs gold | RS money | buy rs money | buy rs gold | cheap rs gold | cheap rs money | Runescape gold | Runescape money | Runescape power leveling | Runescape powerleveling | rs power leveling | rs powerleveling | rs accounts | rs account | runescape accounts | runescape account | rs powerleveling | Runescape powerleveling | rs power leveling | Runescape power leveling | Runescape gold|Runescape Money | Runescape gold|Runescape Money | rs gold|rs Money
Posted by: Runescpae power leveling at 2009年06月23日 15:44