in reply to Building a small perl
First: how much memory does the program use when you just run a syntax check? Or when add a exit; as the very first line of the script? (well the second after a sleep)
Is it the compiled program that is using the memory or is it the code that is being executed at runtime that is using a lot of memory?
What you should be doing (IMHO) is figure out what is using the memory.
One approach could be to add a system("ps -uh $$"); after every line.
IMHO you will not get a serious memory reduction by recompiling perl and setting/unsetting some options. The only way to reduce the memory is to look at the code of the application.
One example to show what I mean:
vsperl -wle 'system("ps uch $$");@x=1..1_000_000;print "Elements in \@x: + " . @x;; system("ps uch $$");' xxx 2395 0.0 1.0 46488 44384 pts/0 R+ 18:46 0:00 perl Elements in @x: 1000000 xxx 2395 0.0 1.5 66104 64012 pts/0 R+ 18:46 0:00 perl
perl -wle 'system("ps uch $$");push @x, $i while ($i++ < 1_000_000);pr +int "Elements in \@x: " . @x;; system("ps uch $$");' xxx 2365 0.0 0.0 3152 1248 pts/0 R+ 18:45 0:00 perl Elements in @x: 1000000 xxx 2365 20.0 0.5 22992 21056 pts/0 R+ 18:45 0:00 perl
Same example but with a syntax check:
vsperl -wlce 'system("ps uch $$");@x=1..1_000_000;print "Elements in \@x +: " . @x;; system("ps uch $$");CHECK { system("ps uch $$"); }' xxx 2554 0.0 1.0 46488 44404 pts/0 R+ 18:50 0:00 perl -e syntax OK
perl -wlce 'system("ps uch $$");push @x, $i while ($i++ < 1_000_000);p +rint "Elements in \@x: " . @x;; system("ps uch $$");CHECK { system("p +s uch $$") }' xxx 2521 0.0 0.0 3152 1260 pts/0 R+ 18:49 0:00 perl -e syntax OK
update: To provider an anwsers on your question about: 'oplines - make perl runtime 8% faster and smaller' that messages is theoretical and you such read it as such. It certainly will not make the runtime of each and every application 8% faster and smaller. It all depends on where the memory is being used.
|
---|