作者sweetwords (米虫三号)
看板Perl
标题[问题] memory out?
时间Wed Sep 24 20:25:56 2008
最近跑一支从 20w 多笔的资料库中,要抓出来其中一个栏位
可是不知道为啥会跑出 memory out 的情况
我下 top 看 memory 资源现在是这样
Mem: 119M Active, 1588M Inact, 209M Wired, 70M Cache, 112M Buf, 8280K Free
Swap: 4096M Total, 245M Used, 3851M Free, 5% Inuse
程式主要是像下面这样,只是一个很简单的从资料库叫出栏位而已 ._.
有 google 一下,主要是说 perl 对於 array 会吃掉太多记忆体
可是不知道我以下这样写,哪里有吃掉很多记忆体呢 QQ?
my $query = "select * from fed_etd_main";
my $sth = $dbh->prepare($query);
$sth->execute;
$sth->bind_col(1,\$identifier,undef);
my $j=1;
while(($sth->fetch))
{
print $j.":".$identifier."\n";
$j++;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.117.74.176
1F:推 LiloHuang:用Devel::Size去看看到底是哪边吃一堆记忆体 09/28 09:12
2F:推 LiloHuang:我怀疑这样query列出的资料太多 可能要用WHERE限制条件 09/28 09:13
3F:推 LiloHuang:或者用LIMIT 限制笔数看看 09/28 09:13