perl 5 まとめウィキ

変数が使用しているメモリ量をしらべることができます。



#!/usr/bin/perl

use warnings;
use strict;
use Devel::Size qw(total_size size);

my $ref ={ hoge => 'hogehoge' , hage => 'hageghe' };

printf("%d\n", size ( $ref ));
printf("%d\n" ,  total_size ( $ref ) );

size と total_sizeの違い


sizeは、参照を深追いしないのに対して、total_sizeは参照先のサイズもカウントします。

危険な点


Devel::Size, because of the way it works, can consume a considerable amount of memory as it runs. It will use five pointers, two integers, and two bytes worth of storage, plus potential alignment and bucket overhead, per thing it looks at. This memory is released at the end, but it may fragment your free pool, and will definitely expand your process' memory footprint.

使用するとフレグメントが起きる可能性があるので注意とのこと。

このページへのコメント

PMsSl4 <a href="http://xrvhnnpmhxjj.com/">xrvhnnpmhxjj</a>, [url=http://hidmjccjwikz.com/]hidmjccjwikz[/url], [link=http://apeycffxmvzw.com/]apeycffxmvzw[/link], http://xizbuqccjpvu.com/

0
Posted by ybyvvb 2013年11月15日(金) 00:09:00 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

Menu

ここは自由に編集できるエリアです。

フリーエリア

どなたでも編集できます