DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 3 of 3 FirstFirst 123
Results 31 to 33 of 33

Thread: Event hook causing memory leak

  1. #31
    Join Date
    Dec 2003
    built-in is anything you did not explicitly write that isnt part of the c++ language proper, as I use the term.

    You are asking the wrong person about in-depth class stuff. If you think you can use those things to make your code work, then you clearly have something in mind, and if it seems to you that it can be made to work, it probably can.

    I go with the KIS method. (keep it simple..). You want to notify a base class? Try this (its very like the singleton idea but replaces an entire class with methods with a single variable and at most 2 supporting methods, possibly less).

    class durr
    static unsigned char twofivefive;

    void poll_myself()
    if(twofivefive == 1)


    The static member is common to ALL the class instances. If *something out there* changes it, you have been notified and shoud handle it.

    You can use the byte as 8 bits (8 booleans, notification of up to 8 things in parallel) or as a single thing (notificaiton of 1 thing, up to 256 different things but 0 should be "no notifiy"), or other such schemes.

    You will have to come up with a strategy to clear the notification once all the instances have handled it work out the details within your design, but its all you need. If you think the class method is cleaner, go for it, its basically the same idea (just seems overkill).

    if your target hardware is dual core, you should be using threaded method to do the data processing, if at all possible, to double your throughput. By default, if you do not thread the code, it will all sit on one core. These days, for high performance apps, its best to detect the number of processors and have logic to divide and conquor for up to 8, or even 16, possible processors just in case if you expect the app to have a long life span, or at least 4 as even casual computer users have quad cores now.

  2. #32
    Join Date
    Jul 2010
    funny you should mention threading, thats How I was going to set it up once I was done. Problem is, everytime I finish implementing something in the class, I come up wth two more ideas that I think the class should have so that now I am wondering if it will ever be "Finished". I didnt start off with the threaded model because when working with forms I have to do all the post or call back methods to update labels and textboxes and such, and its not the base class I am trying to notify, I am trying to notify all the instances of the derived class when a change is made to the base class.

    I am a firm believer in simple, and I thought that using events would be the simplest, and actually it was simple to implement, but I didnt forsee the side effects of it. Keeping it simple was also the reason the class was creating so many temporary instances of itself.

  3. #33
    Join Date
    Dec 2003
    Static still works. If the base changes, the static notifier changes, and the derived classes can see that, right? Its simply a matter of checking the variable and developing a scheme to manage this info (so you can reset the notifier and ensure that all derived classes have seen it and acted upon it as needed).

    You could even cheat since you are using the windows form stuff. Edit boxes, for example, have a built in handler for "on change". You can derive a mess from a class like this, set up the on-change, backfeed the base class data into the derived edit box and let the derived on-change handler kick in for you... =) This would be more of keeping it lazy than keeping it simple though, its a very messy way to get the job done in a hurry and I do not really recommend it and only mentioned it as an example of the power of the libraries.

Similar Threads

  1. Possible Memory Leak in Java application
    By esi-eric in forum Java
    Replies: 3
    Last Post: 02-24-2005, 07:58 PM
  2. Announcing a memory leak in javax.comm
    By Jason Jakob in forum Java
    Replies: 0
    Last Post: 06-30-2002, 01:14 PM
  3. help memory
    By kathy in forum Java
    Replies: 0
    Last Post: 11-02-2001, 05:22 PM
  4. Interface leaks in C#?
    By Kevin Burton in forum .NET
    Replies: 12
    Last Post: 10-09-2000, 10:29 AM
  5. Re: MS Provider For Oracle : Memory Leak ?
    By John Grandy in forum VB Classic
    Replies: 0
    Last Post: 04-08-2000, 08:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center