Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^10: Tk and Threads

by zentara (Archbishop)
on Dec 22, 2010 at 12:54 UTC ( [id://878508]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Tk and Threads
in thread Tk and Threads

If you then create another new thread from within that first thread, it also will not have any of the tk stuff that you created in the main thread after you started the work thread.

It sounds good, but I wonder what sort of memory gains would occur, with that initial thread repawning itself ad infinitum?


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^11: Tk and Threads
by BrowserUk (Patriarch) on Dec 22, 2010 at 13:16 UTC
    with that initial thread repawning itself ad infinitum?

    On Windows, none. On *nix, from previous threads it appears that the implementations leaks a few k for each new thread.

    But unless the OP is intending that the buttons on this Tk gui be used as those on a gmaes controller in a first person shoot'em up, even the *nix leak is unlikely to be a big problem.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Well the OP said he was running some heavy code from the threads. So that probably means he's going to be importing some modules, like CGI, DBD, PDL?, whatever.....and that code will now be incorporated into the next spawned thread, in the copy-on-create process. This is going to cause problems in subsequent generations.... as it's parent was contaminated by previous code.

      Your interesting solution, would require spawning 1 primordial virgin thread, which is used for nothing more than to spawn more clean threads. Because that virgin copy, cannot import any modules, without polluting it's own next copy, it can only have a breeder function. Having that breeder thread laying there, just to spawn more, is quite wasteful.

      On linux, there comes a time to fork. I advocate forking from the threads, so that the threads only get created once, and act as controllers for the forked code they run.

      This is the big difference between threads on Windows and Linux. On linux, there is a distinction between forking and threads, whearas on Windows fork() is emulated.

      On linux, forking code has many advantages over threads, the memory cleanups are better, and probably faster, and thread safety of modules becomes a non-issue.


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://878508]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-16 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found