View Answer

It can definitely be a dispose issue. When you dispose the client it cancels any outstanding async operations.

You should dispose the client in Email_OnCompleted.

An SO post on where to dispose: Dispose SmtpClient in SendComplete?

Score: 18
Comments: 4
Date posted: 11/29/2011

View Answer

I suggest using the libgdx life-cycle methods

To dispose you should use the dispose() method. You don't need to call dispose yourself! It will be called automatically when the application gets destroyed, see documentation:

dispose () Called when the application is destroyed. It is preceded by a call to pause().

So just implement the dispose method in your Screens:

public void dispose () { 
    //your code needs to get added here, like for example:

Update: Note that dispose() of AppliacationListener gets called automatically, not dispose() of Screen, see comment of Springrbua

Score: 5
Comments: 4
Date posted: 4/8/2014

View Answer

When a method hands off an IDisposable instance, it is simultaneously handing over the lifetime management responsibility.

It is now the caller's responsibilty to dispose of the object after use. If that object contains other IDisposable objects, by convention we must expect the container to properly dispose of its children when we dispose it - otherwise it would imply a bug in the container.

In your concrete example, you should expect the Pen to dispose of its internal Brush instance when you dispose it.

Score: 0
Comments: 2
Date posted: 10/8/2009

View Answer

The Classes you have created hold huge amount of data (Class A, Class B, BigClass for example). Whenever you create and use classes like these which hold many data (specially value type) you have to tell the runtime to destroy (or Dispose) them when you don't need them anymore. This is called "The Dispose Pattern" and you can find out more about it here:

Some .net Classes have built in Dispose() method so that the ,Net Garbage Collector (GC) knows when to wipe them out of memory. but not all of them. for those who have Dispose() and implement IDisposable interface you can use "Using" statement to automatically dispose them when their task has finished (you have used some using statement in your code but not in all required places).

Simple answer is: your data remain in memory after serialization has finished. make your classes disposable and dispose them when you don't need them.

[This question is helpful for you: When should I dispose my objects in .NET? ]

Score: -1
Comments: 0
Date posted: 6/9/2017

View Answer

Calling the finalizer is done by the garbage collector. To have perfect control over unmanaged resources, use a disposable pattern

class MyResource : IDisposable

  public void Dispose()
    GC.SuppressFinalize(this); // don't finalize after the object has already been disposed of

  protected void Dispose(bool disposing)
      // TODO: Dispose managed resources

    // TODO: Dispose unmanaged resources

// when using
using(var resource = new MyResource())
  // ... use resource
} // when out of "using" scope, it will be disposed
Score: -1
Comments: 1
Date posted: 9/12/2018


© 2021 Search Overflow
Contributions licensed under cc by-sa