Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6147389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:06:10+00:00 2026-05-23T19:06:10+00:00

We consider to use the Prism event aggregator for the purpose of reducing memory

  • 0

We consider to use the Prism event aggregator for the purpose of reducing memory leaks due to event references.

  1. Is this for itself a valid reason to use this pattern? The other benefits are not interesting for us now. We plan to use it between model components and not UI.

  2. Our problem was that some developers forgot to unregister events. I saw that Prism has one flavour which uses weak references but it has limitations. The other flavour forces to explicitly Unsubscribe(), which again can be forgotten. So how is it better?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:06:11+00:00Added an answer on May 23, 2026 at 7:06 pm

    Our problem was that some developers forgot to unregister events

    If this is your problem, switching to the Prism event aggregator (or, using any other implementation) won’t improve things.

    Adding a new dependency with a new, non-trivial, usage pattern into a messy situation isn’t going to tidy it up at all.

    What you need is to clean up your code.

    Instead of new code libraries, I’d suggest looking into static analysis tools like fxCop (aka Code Analysis), Gendarme and NDepend. All of these are able to detect some situations where events are not unhooked or where IDisposable is not implemented properly.

    Using static analysis, you can dispassionately identify code that needs cleanup. Throw in use of a memory profiler (like dotTrace Memory) and you’ll be able to find the worst offenders and clean them up promptly.

    Update

    In answer to the question in the comment below:

    What do you suggest as a good pattern for ensuring that events get unhooked?

    In can be difficult to make sure that all events are unsubscribed – but given the way that events are implemented (see CLR via C# for details), you can cheat a little by ensuring all event subscriptions are discarded.

    Instead of

    public event EventHandler<Fu> FuBar;
    

    handle the event subscription yourself, like this:

    public event EventHandler<Fu> FuBar {
        add { mFuBar += value; }
        remove { mFuBar -= value; }
    }
    
    private EventHandler<Fu> mFuBar;
    

    Then, implement IDisposable on your class, and in your Dispose() method set mFuBar to null, discarding the subscriptions. FxCop (and other tools) can then tell you if you are failing to Dispose of the class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this scenario. I have my own website, that I use as my identifier,
Hopefully someone can help me out on this one. Consider the following use-cases: Add
Consider: print $foo, AAAAAAAA, $foo, BBBBBBBB; Let's say I want to use this code
Consider this use case scenario: I wish to auto complete and provide the skeleton
I have to admit, this one has me foxed. Consider this code: use version;
Consider this snippet: use strict; use warnings; my $data = 1; my $packed =
This may seem like a silly question, but consider the following use of the
Consider this try / except block I use for checking error message stored in
Consider the following use case 1. User selects a product to purchase on seller's
Please consider the following simple use case: public class Foo { public virtual int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.