Home > Archive > PERL Beginners > February 2006 > Fork or Thread?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Sky Blueshoes 2006-02-23, 3:55 am |
| I have a Net::IRC application that uses a Win32::GUI interface. My GUI
is lagging and I was wondering what would be better to use and how would
I go about it. Should I fork the Net::IRC process (how?) or I've read
about Threads (not stable?). Any suggestions, hints, tips, LINKS to
documentation are extremely welcome.
Sky Blueshoes
| |
| Zentara 2006-02-23, 9:55 pm |
| On Wed, 22 Feb 2006 23:30:49 -0600, skyblueshoes76@sbcglobal.net (Sky
Blueshoes) wrote:
>I have a Net::IRC application that uses a Win32::GUI interface. My GUI
>is lagging and I was wondering what would be better to use and how would
>I go about it. Should I fork the Net::IRC process (how?) or I've read
>about Threads (not stable?). Any suggestions, hints, tips, LINKS to
>documentation are extremely welcome.
>
>
>Sky Blueshoes
Threads are stable, if you know how to handle them. They
have to be used carefully. Basically, unless stated otherwise
in their docs, objects cannot be used across threads. It
is well discussed, just google for it.
Back to your immediate problem:
Fork is done using threads on Win32, see
http://perlmonks.org?node_id=498719
basically it recommends using Win32::Process
Without really seeing you code ( and not using win32), I would say your
big problem, is if you use a pure threaded solution, (without the fork
emulation) is watching your memory usage. The solution to that problem,
is to reuse your threads... that is have a bank of threads to handle
connections, and reuse them as one connection drops, and another comes
in. If you spawn new threads for each connection, and just let them
go when done with them, you may accumulate memory. It would be
better to spawn independent processes, with Win32 ::Process (or fork
emulation). That way, when a connection dies, the memory is easily
reclaimed into the system.
You will see all these problems as you test various solutions. But you
big concern overall, is to find a solution that releases ( or reuses )
memory after a connection closes. Otherwise, you will find that you
need to restart your server, to reclaim memory, at regular intervals.
YUCK.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
|
|
|
|
|