in reply to threads causing memory leak

You say "the code is called every 30 seconds" - do you mean you create a new thread every 30 seconds? Do you ever ->join that thread? Otherwise, I think you should use async. Personally, I would put the fetched results in a Thread::Queue and retrieve it from there in the main thread, so that all updating of new data happens within the main thread and only the fetching happens asynchronously, using ->dequeue_nb().

As Win32::GUI is event-driven, it might even make sense to have the worker thread send a window message to the main program to tell it to fetch the result.

Replies are listed 'Best First'.
Re^2: threads causing memory leak
by holli (Abbot) on Sep 11, 2010 at 13:43 UTC
    do you mean you create a new thread every 30 seconds?
    Yes.
    Do you ever ->join that thread?
    No, i wait for it to finish.
    Otherwise, I think you should use async.
    async?

    Update:
    Using async does not help, same problem. joining the thread leads to:
    Free to wrong pool 9f2520 not 3f4e10 at c:/strawberry/perl/vendor/lib/ +Win32/GUI.pm line 2703 during global destruction.


    holli

    You can lead your users to water, but alas, you cannot drown them.
      No, i wait for it to finish.

      That's exactly what join does. But if you don't join it, it's memory is never returned to the memory pool.

      Free to wrong pool 9f2520 not 3f4e10

      That's a bug in Win32::GUI.


      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.
        WxPerl Windows will probably crash too. I will test it when I have some time.