On Feb 18, 6:34 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2007-02-18 09:12, RJ <jain.n...@gmail.com> wrote:
>
> > On Feb 16, 4:38 pm, anno4...@radom.zrz.tu-berlin.de wrote:
> >> RJ <jain.n...@gmail.com> wrote in comp.lang.perl.misc:
> >> > First of all, if I just do a `require"<generated_file.pl>" ` it takes
> >> > a lot of memory (around 4Mb for 2 Mb file even if I do just a return
> >> > after entering pass_data_from_perl_to_c and populate no Data).
> >> > If I do populate data in form of 3-D array is perl memory requirement
> >> > is 5 times than expected.
>
> >> Perl often takes more memory than expected. Adjust your expectations.
>
> > My main concern here is that even if return from very beggining of
> > function pass_data_from_perl_to_c , even then perl takes a lot of
> > memory in just requiring file '<generated_file.pl>' while I am
> > populating no data structures.
>
> I don't understand what you expect to happen when you "justrequire" the
> file. When yourequirea file, it is compiled and the compiled code is
> stored in memory. Any data embedded in the code is of course compiled
> (converted to perl data structures) and stored, too.
>
I just want to clarify one thing over here. There are only function
calls in these generated
perl file. It looks something like follows -
<Prototype>
<spyDecompileTagData(index,rName,{"t1" => "1","t2" =>
["100","200"],"t3" => "200"});>
<Example snippet>
================================================== ====================================
spyDecompileTagData(537,"",{"INCR" => "1","tag1" =>
["100","200"],"tag0" => "200"});
spyDecompileTagData(538,"",{"INCR" => "1","tag2" =>
"tag2.value2","tag3" => "default"});
spyDecompileTagData(539,"",{"INCR" => "1","tag4" =>
["tag4.value1","tag4.value3"]});
spyDecompileTagData(540,"",{"INCR" => "1","tag1" => ["200"]});
spyDecompileTagData(541,"",{"INCR" => "1","tag1" => ["200"]});
spyDecompileTagData(542,"",{"INCR" => "1","tag4" => ["default"]});
spyDecompileTagData(543,"",{"INCR" => "1","tag4" => ["tag4.value3"]});
spyDecompileTagData(544,"",{"INCR" => "1"});
spyDecompileTagData(545,"",{"INCR" => "1","tag1" => ["200"]});
spyDecompileTagData(546,"",{"INCR" => "1"});
spyDecompileTagData(547,"",{"INCR" => "1","tag1" => ["200"]});
spyDecompileTagData(548,"",{"INCR" => "1"});
spyDecompileTagData(549,"",{"INCR" => "1"});
spyDecompileTagData(550,"",{"INCR" => "1","tag4" => ["tag4.value1"]});
spyDecompileTagData(551,"",{"INCR" => "1","STATUS" => "FIXED"});
spyDecompileTagData(552,"",{"INCR" => "1","STATUS" => "TOFIX"});
spyDecompileTagData(553,"",{"INCR" => "1","STATUS" => "ANALYZE"});
spyDecompileTagData(554,"",{"INCR" => "1","tag9" => "1","tag8" =>
"3.14","tag7" => "a"});
spyDecompileTagData(555,"",{"INCR" => "1","tag11" => "2","tag12" =>
"1","tag9" => "2","tag8" => "9.8","tag0" => "0","tag7" => "c"});
================================================== ====================================
There is no other things in this perl file other than these function
calls.
Now if I just make a return from inside 'spyDecompileTagData' after
doing 3 shift stmts (one for each argument passed to this function),
still perl takes a lot of memory. I have used above format just to
avoid parsing as I you can see the values passed in 3rd argument can
be quite complex (a hash whose values can be scalar/array refrence or
even a hash refrence. I don't want perl to store
the whole file in code section but I want to compile code inline. Is
there anyway to do so.
> > Is there anyway to avoid that (or some way to execute the function
> > calls in ,'<generated_file.pl>' infile without loading file in
> > memory), since there can be case , when I have to 'require'
> > this file but I would need not populate single information from here.
>
> Separate the data from the code. Perl is good for reading and writing
> files - use it!
>
> hp
>
> --
> _ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
> |_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
> | | | h...@hjp.at | andere ersetzt.
> __/ |http://www.hjp.at/| -- Nils Ketelsen in danr