On 23 Feb 2005 04:32:56 -0000, via RT Fergal Daly <[EMAIL PROTECTED]> wrote: > # New Ticket Created by Fergal Daly > # Please include the string: [perl #34230] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34230 > > > This is a bug report for perl from [EMAIL PROTECTED], > generated with the help of perlbug 1.34 running under perl v5.8.0. > > ----------------------------------------------------------------- > [Please enter your report here] > > #! perl -slw > use strict; > use Data::Dumper; > > $Data::Dumper::Deepcopy = 0; > my %h; > $h{ $_ } = [ 1 .. 10 ] for 'aaaa' .. 'zzzz'; > print Dumper \%h; > > eats gigs of memory, I have no idea how long it takes to finish, if it all. > It's because DD catalogs every scalar even when deepcopy is off. Attached is > a patch against 2.121 to stop cataloging when Deepcopy is off. I don't think > there's another reason to catalog scalars but I could be wrong.
DD needs to catalog scalars so it can handle cyclic references and self referential data structures. Consider: my @array=(1..10); my %hash=(a=>\$array[2]); print Dumper([EMAIL PROTECTED],\%hash); Id be really surprised if DD passed self test with this change applied. Also, im confused about this patch. Why arent you using the XS code? With the code youve posted I would expect DD to use the XS code, and the patch youve posted wouldnt change its behaviour. Not that the XS is any better in this regard, im just confused why you think this patch should work. Incidentally you might want to check out Data::Dump::Streamer which will handle this type of thing much more gracefully as it will only catalog those SV's with a refcount over 1. Its also better as it doesnt necessarily build the output in memory first which is another reason your dump is taking forever. Each key and value results in a realloc call to extend the print buffer that DD. So for the dump above you are looking at about 1_000_000 realloc calls with the memory copying requirements associated with that call. DDS has the advantage of turning that into 1_000_000 print statements instead. :-p cheers, Yves -- First they ignore you, then they laugh at you, then they fight you, then you win. +Gandhi
