I have a weird problem, an "Out of memory" one. The weird thing is that the script I have is not even started when I get that error (I mean, I have a print line in the very beginning and it is not printed) and the memory meter does not move at all. Please help me with this situation.
My OS is Ubuntu.
I have marked the lines that when removed the "Out of memory" error is gone:
#!/usr/bin/perl sub dictionary { while (($n = read FILE, $data, 1) != 0) { $nr += $n; if($data eq "e") {return;} if($data eq "d") {dictionary();} if($data eq "l") {list();} if($data eq "i") {integer();} if($data eq ":"){ print LOG $buf."\n\n"; [COLOR=red]$n = read FILE, $data, $buf;[/COLOR] $nr += $n; [COLOR=red]$buf="";[/COLOR] print LOG $data."\n\n"; } [COLOR=red]else { $buf .= $data;}[/COLOR] } } sub list { while (($n = read FILE, $data, 1) != 0) { $nr += $n; if($data eq "e") {return;} if($data eq "d") {dictionary();} if($data eq "l") {list();} if($data eq "i") {integer();} if($data eq ":"){ print LOG $buf."\n\n"; [COLOR=red]$n = read FILE, $data, $buf;[/COLOR] $nr += $n; [COLOR=red]$buf="";[/COLOR] print LOG $data."\n\n"; } [COLOR=red]else { $buf .= $data;}[/COLOR] } } sub integer { while (($n = read FILE, $data, 1) != 0) { $nr += $n; if($data eq "e") {return;} $buf .= $data; } #print LOG $buf."\n\n"; print $n."\n"; } { print "started"; open FILE, "test.torrent" or die $!; open LOG, ">log" or die $!; binmode FILE; my ($buf, $data, $n, $nr); $nr=0; while (($n = read FILE, $data, 1) != 0){ if($data eq "d") {dictionary();} if($data eq "l") {list();} if($data eq "i") {integer();} } close(FILE); close(LOG); }The purpose of the file is to read a torrent file section by section and it is incomplete.
Thanks in advance
Edited by sakishrist, 13 April 2011 - 11:11 AM.