Loading ...
Sorry, an error occurred while loading the content.

I have read the Performance section. Yet: Large items take huge amount of memory

Expand Messages
  • pinchuk
    Hello, I have read whatever I could find about this problem. I tried all the suggestions and guidelines. Nothing helps. Below you can find a sample code that
    Message 1 of 1 , Jul 31, 2003
    • 0 Attachment
      Hello,

      I have read whatever I could find about this problem. I tried all the
      suggestions and guidelines. Nothing helps.

      Below you can find a sample code that demonstrate the problem

      In the following code, I have a SOAP::Lite daemon that simply return a
      BLOB of whatever file it is asekd (OK - it is not secure, but as an
      example for the problem it will do):

      daemon.pl:

      #!/usr/local/bin/perl -w

      use strict;
      use warnings;
      use utf8;
      use SOAP::Transport::HTTP;
      use Bug;

      $| = 1;
      $ENV{PERLIO} = ":raw";

      my $port = $ARGV[0] || 8888;
      my $host = $ARGV[1] || "localhost";

      my $daemon = new SOAP::Transport::HTTP::Daemon( LocalAddr => $host,
      LocalPort => $port);

      unless ($daemon) {
      print "cannot create a daemon on port $port";
      exit;
      }

      $daemon->dispatch_to('Bug::test');
      print "cdi.daemon is listening on ". $daemon->url()."\n";
      $daemon->handle();

      Bug.pm:

      package Bug;
      use strict;
      use warnings;
      use SOAP::Lite;

      #############
      # test
      #############
      sub test {
      my $self = shift;
      my $path = shift;
      open(FILE, $path) || print "failed to open $path\n";
      my $blob;
      read(FILE, $blob, -s FILE);
      close(FILE);
      my $returned_value = SOAP::Data->type(base64 => $blob);
      print "till here it went quite easy. now watch it!\n";
      return $returned_value;
      } # of test

      1; # make perl happy

      test.pl:

      #!/usr/local/bin/perl -w
      use strict;
      use warnings;
      use diagnostics;
      use Data::Dumper;

      $| = 1;

      my $port;
      my $host;
      my $proxy;

      BEGIN {
      $port = $ARGV[0] || 8888;
      $host = $ARGV[1] || "localhost";
      $proxy = 'http://'.$host.':'.$port;
      }
      # connect to the SOAP daemon
      use SOAP::Lite +trace => ( 'debug' ) =>
      #use SOAP::Lite
      dispatch_from => [ 'Bug' ] =>
      uri => 'Bug',
      proxy => $proxy;

      my $blob = Bug->test("path/to/a/big/file");
      print Dumper $blob;


      Now, the problem is that it takes too much memory when the file a bit
      big. For example for about 4M, the daemon takes more then 80M, and for
      about 8M the daemon takes about 170M !

      I tried many things - I read the performance section in the man page,
      and as you see above, I use base64. I checked many files. It seems
      that SOAP::Lite takes too much memory to process it.

      Is there anyway to bypass this problem (even by creating part of the
      XML in my code and concat it somehow to the rest of the XML)?

      Any suggestions please.

      Thanks a lot,

      Rani
    Your message has been successfully submitted and would be delivered to recipients shortly.