Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I created a perl socket server using use Danga::Socket::AnyEvent and Danga::Socket::Callback which basically used AnyEvent::HTTP

Anyways the problem is that there is a slow memory leak ,and when using Devel::Gladiator arena_table() function I see:

ARENA COUNTS: 475641 REF 333577 SCALAR 105335 REF-CODE 103141 HASH 101462 REF-HASH 99024 ARRAY 82090 REF-Tie::RefHash::Nestable 74231 REF-ARRAY 69084 REF-Tie::RefHash::Weak 49129 Tie::RefHash::Nestable 39068 REF-Danga::Socket::GCallback 17199 Danga::Socket::GCallback 4827 GLOB 4155 CODE 2062 REF-AnyEvent::Loop::io 1201 REF-SCALAR 1048 IO::File 1032 REF-IO::Socket::INET 1031 AnyEvent::Loop::io 1031 IO::Socket::INET 576 REGEXP 58 Regexp 57 REF-Regexp 7 VSTRING 6 Tie::RefHash::Weak 4 Encode::XS 4 REF-Encode::XS 3 REF-Encode::utf8 2 Encode::utf8 2 FORMAT 2 REF-Config 2 REF-version 2 pseudohash 2 version 1 AnyEvent::CondVar 1 Config 1 Encode::Internal 1 Errno 1 LVALUE 1 POSIX::SigRt 1 Protocol::WebSocket::Frame 1 Protocol::WebSocket::Handshake::Server 1 Protocol::WebSocket::Request 1 Protocol::WebSocket::Response 1 REF-AnyEvent::CondVar 1 REF-Encode::Internal 1 REF-Errno 1 REF-POSIX::SigRt 1 REF-Protocol::WebSocket::Frame 1 REF-Protocol::WebSocket::Handshake::Server 1 REF-Protocol::WebSocket::Request 1 REF-Protocol::WebSocket::Response

The first main problem I think is that REF-Tie::RefHash::Nestable, Tie::RefHash::Nestable seem way too high.

The only use of them is

tie %clients, 'Tie::RefHash::Weak'; tie %users, 'Tie::RefHash::Weak'; tie %connectionCheck, 'Tie::RefHash::Weak'; tie %connectionType, 'Tie::RefHash::Weak'; tie %hs, 'Tie::RefHash::Weak'; tie %frame, 'Tie::RefHash::Weak'; tie %rooms, 'Tie::RefHash::Nestable';

But, when counting/logging them using the following code:

print FILE '%clients: ' . scalar(keys %clients) . ' ' . total_size +(\%clients) . "\n"; print FILE '%users: ' . scalar(keys %users) . ' ' . total_size(\%u +sers) . "\n"; print FILE '%connectionCheck: ' . scalar(keys %connectionCheck) . +' ' . total_size(\%connectionCheck) . "\n"; print FILE '%connectionType: ' . scalar(keys %connectionType) . ' +' . total_size(\%connectionType) . "\n"; print FILE '%hs: ' . scalar(keys %hs) . ' ' . total_size(\%hs) . " +\n"; print FILE '%frame: ' . scalar(keys %frame) . ' ' . total_size(\%f +rame) . "\n"; print FILE '%rooms: ' . scalar(keys %rooms) . ' ' . total_size(\%r +ooms) . "\n";

The output is low such as:

%clients: 1035 2919225 %users: 1038 2919225 %connectionCheck: 767 2919225 %connectionType: 1035 2919225 %hs: 1 2919225 %frame: 1 2919225 %rooms: 213 3292324

All of the references are to RefHash objects are to Danga::Socket::Callback and are deleted by using code such as delete($users{$client}) when the client disconnects. It seems impossible that the scalar(keys %hashes) numbers could add up to the large 69084 REF-Tie::RefHash::Weak number shown on arena counts. Am I missing something? Thanks


In reply to Memory leak detection by runnerup

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-18 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found