Hello. Thanks for the replies. Here is a little bit of my perl script i wrote. The problem is: At start time it uses 10MB Memory. And if a user writes a message ( SENDMESSAGE ) , it needs for every message ( 300 KB of memory ). Now ... how can i fix the problem?
use feature 'state'; use Time::HiRes; require "config.cfg"; require "Subs.pl"; require "format.pl"; require "server/mainprogram_subs.pl"; require "ConnectDB.pl"; require "loadconfig.pl"; require "$config{language}.lng"; require 5.002; use IO::Socket::SSL 'inet4'; $IO::Socket::SSL::DEBUG = 3; use IO::Select; use Time::HiRes; use HTML::Template; use Text::Wrap; use Fcntl ':flock'; use strict; no strict 'refs';
later in my program:
if($buffer =~ /^SENDMESSAGE$digest\|(.*?)$/){ my $what = $1; my($room,$touser,$kind,$message,$fromuser)= +split /\|/, $what; my $myuser = $fromuser; my $update_sock = getCurrentIdent($myuser); if( SockExists($update_sock) ) { $clients{$update_sock}->{lastsrvpost} = ti +me; } if($touser eq "" && $room ne "" && $kind ne +"PRVMESSAGE") { sendToSocket($message, { toroom => $room, kind => + $kind, fromuser => $myuser } ); }elsif($touser ne "" && $room eq "" && $kind + ne "PRVMESSAGE" ) { sendToSocket($message,{ fromuser => $myuser, tou +ser => $touser, kind => $kind } ); }elsif($touser eq "" && $room eq "" && $kind + ne "PRVMESSAGE") { sendToSocket($message, {}); } next;
and the sendToSocket routine is the following:
sub sendToSocket { my( $data, $params ) = @_; if( $data eq "" ) { return 0; } if( $params->{toroom} ne "" && $params->{touser} eq "" ) { foreach my $ident( keys %clients ) { our $nick = $clients{$ident}->{nick}; if( isInIgnorelist($nick, $params->{fromuser}) && $co +nfig{ignore_modus}{$params->{kind}}==1) { }else{ my %info = loadMemberInfo($nick); if( lc $params->{toroom} eq lc $info{room}) { my $fh = $clients{$ident}->{sock}; if( defined $fh ){ my $msg = createFilter($ident, $data); $fh->syswrite($msg . "\n"); undef $fh; undef $msg; undef %info; undef $nick; } } } } }elsif( $params->{toroom} eq "" && $params->{touser} ne "" ) { my $user = $params->{touser}; my $sock = getCurrentSocket($user); my $sn= $sock->{sockname}; my $socket = $sock->{socket}; my $ident = getCurrentIdent($user); if( isInIgnorelist($clients{$sn}->{nick}, $params->{from +user}) && $config{ignore_modus}{$params->{kind}}==1 ) { }else{ if( defined $socket ){ $msg = createFilter($ident, $data); $socket->syswrite($msg . "\n"); undef $msg; undef $ident; undef $sock; } } }elsif( $params->{touser} eq "" && $params->{toroom} eq "" ) { foreach my $ident( keys %clients ) { my $sock = $clients{$ident}->{sock}; $msg = createFilter($ident, $data); if( defined $sock ){ $sock->syswrite($msg . "\n"); } undef $msg; undef $sock; } } }
But if i use undef, nothing happens. It still uses the memory :( Hope you can help. Thanks Regards Sascha

In reply to Re: Perl Memory problem ... by Sascha2018
in thread Perl Memory problem ... by Sascha2018

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.