Google Answers Logo
View Question
 
Q: Perl deugging / profiling: Checking runtime variable size ( No Answer,   2 Comments )
Question  
Subject: Perl deugging / profiling: Checking runtime variable size
Category: Computers > Programming
Asked by: snowcat-ga
List Price: $10.00
Posted: 23 Oct 2003 07:59 PDT
Expires: 22 Nov 2003 06:59 PST
Question ID: 269025
Hi,

I need to fix the following error in my perl program: 

Out of memory during "large" request for 16781312 bytes, total sbrk()
is
1247642432 bytes at /spfs/reports/bin//cobanalyzer.pl line 4948, <JSP>
line 5319224.

The line 4948 is:   $query{$key} = $val;

I only have time to change a few lines, so, is there any way I can
identify which variables / hashes consume the most memory so that I
can only optimize a coupld of places?

Thanks,
Matt
Answer  
There is no answer at this time.

Comments  
Subject: Re: Perl deugging / profiling: Checking runtime variable size
From: douglas_hunter-ga on 31 Oct 2003 13:48 PST
 
You probably want to tie your hash to an on-disk hash.  BerkeleyDB's
Perl interface is a good solution to a problem such as this.  Here is
some sample code to get you started:

<sample>

#!/usr/bin/perl

use warnings;
use strict;

use BerkeleyDB;

my %query;

my $db = tie %query, 'BerkeleyDB::Btree',
    -Flags    => BerkeleyDB::DB_CREATE,
    -Filename => 'query.db' or die "$!, $BerkeleyDB::Error";


$query{ "key" } = "val";

# and later ...

warn "key has a value of: ", $query{ "key" };

</sample>

If you really want to see the size of your Perl datastructures, you
could use Devel::Size (also available from the CPAN).

Hope that helps a bit.

-- Douglas
Subject: Re: Perl deugging / profiling: Checking runtime variable size
From: snowcat-ga on 31 Oct 2003 14:34 PST
 
Douglas,

Thanks for the help. If any of the following 3 directions works, I'm
done.

1) I installed Devel::Size. But I did not find info about how to view
the hash size such as: $spc_info_{yp}{$mem}{$spc}{$spc_t}

"total_size(\%spc_info_)" seems suspicious.

2) BerkeleyDB is interesting. How can I install it without root
privilege?

3) I have Oracle 8 installed, how can I use Oracle instead of
BerkleyDB here?

Thanks,
Matt

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy