×

Discussion Board

Page 3 of 3 FirstFirst 123
Results 31 to 33 of 33
  1. #31
    Registered User
    Join Date
    May 2014
    Posts
    9

    Re: Creating CustomEffect in C++, NullReferenceException

    Actually, not calling dispose on an IDisposable does not guarantee a leak of native resources, and this has never been a "norm" in .NET. Classes implementing IDisposable usually have a finalizer that is called when the GC eventually cleans up.

    This assumes that the GC can in fact do its job, which it can when the reference cycle involves only .NET objects. It then has the ability to walk the object graph and prove that there are no "root" references left - and can chuck away the whole cycle. However when you cross the border to WinRT so that one object is managed and one is native and they both refer to each other, you're stuck. The GC can no longer detect the cycle and therefore cannot run finalizers and clean up.

    So it's not a question of deallocation being delayed. It just won't happen. (!)

    And to reiterate, we do think users should dispose, to ensure deterministic deallocation. I fully agree, it's crucial in memory constrained scenarios. But that's slightly different from requiring a call to Dispose under the penalty of leaking memory forever.

    We basically chose the lesser of two evils.

    And again, in the wrapping pattern shown by CustomEffectBase, the "weakness" can be hidden rather naturally.

  2. #32
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    475

    Re: Creating CustomEffect in C++, NullReferenceException

    Quote Originally Posted by cadahl View Post
    Actually, not calling dispose on an IDisposable does not guarantee a leak of native resources, and this has never been a "norm" in .NET. Classes implementing IDisposable usually have a finalizer that is called when the GC eventually cleans up.
    Yep, but GC can begin to deallocate managed class with lower memory used like it doesn't take in count native memory size. So, you can have a high memory used with more possibility to generate out of memory exception.

    Quote Originally Posted by cadahl View Post
    this has never been a "norm" in .NET
    I don't know if it a "norm" but It's one the first thinks i've learn with C#. Always use using or call dispose with IDisposable class. Because if a class is IDisposable, it's normally to avoid possible problem with GC.

    For a full managed class( don't use native class), i don't see real interest.

    Quote Originally Posted by cadahl;939476This assumes that the GC can in fact do its job, which it can when the reference cycle involves only .NET objects. It then has the ability to walk the object graph and prove that there are no "root" references left - and can chuck away the whole cycle. However when you cross the border to WinRT so that one object is managed and one is native and they both refer to each other, you're stuck. The GC can no longer detect the cycle and therefore cannot run finalizers and clean up.

    So it's not a question of deallocation being [B
    delayed[/B]. It just won't happen.
    I've understand it's one reason of IDisposable concept. Resolve problem between managed and native code.

    And to reiterate, we do think users should dispose, to ensure deterministic deallocation.
    I've understand the opposite. It's why i was surprised ^^ sorry

    I fully agree, it's crucial in memory constrained scenarios. But that's slightly different from requiring a call to Dispose under the penalty of leaking memory forever.

    We basically chose the lesser of two evils.
    Thanks a lot for your explanation.

    If i understand, DelegatingFilter and DelegatingEffect use weak reference?
    Which other class use weak reference?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  3. #33
    Registered User
    Join Date
    May 2014
    Posts
    9

    Re: Creating CustomEffect in C++, NullReferenceException

    Happy to help! If I recall correctly, only the Delegating* family of classes use weak references in this way. So that adds DelegatingImageSource to the two others you mentioned.

Similar Threads

  1. Replies: 4
    Last Post: 2009-11-24, 13:12
  2. Creating lacal SMS creating panic..
    By amol_benare604 in forum Symbian
    Replies: 2
    Last Post: 2009-11-02, 13:50
  3. Creating a Dialog and creating textboxes,checkboxes
    By tharunjavalimn in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-10-26, 14:00
  4. Creating Themes on the Fly ( creating the SIS file )
    By bayugyug in forum Streaming and Video
    Replies: 0
    Last Post: 2005-10-20, 12:16
  5. Creating MTM HELP!!!!
    By pajak in forum Smart Messaging
    Replies: 0
    Last Post: 2004-01-23, 12:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×