Questions tagged [dispose]

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources

Microsoft.NET

The pattern for disposing an object, referred to as a dispose pattern, imposes order on the lifetime of an object. The dispose pattern is used only for objects that access unmanaged resources. This is because the garbage collector is very efficient at reclaiming unused managed objects.

A type's Dispose method should release all the resources that it owns. It should also release all resources owned by its base types by calling its parent type's Dispose method. The parent type's Dispose method should release all resources that it owns and in turn call its parent type's Dispose method, propagating this pattern through the hierarchy of base types.

Reference

1987 questions
0
votes
2 answers

C# Memory Leak on SQL Server data fetch

I have created a simple data fetch method which fetches data from a SQL Server database. Each time I fetch data by calling this method the memory grows (application pool memory). When I explicitly call GC.Collect() after fetching the data, the…
Sam
  • 1
  • 5
0
votes
1 answer

C# Dispose() standard with certain situation

We know Dispose(bool disposing) should be protected or private, what if i need to manually release the unmanage resources? Dispose() from interface IDISPOSIBLE must call Dispose(true) which means release all resource. i want to manually control the…
xiaojiuwo
  • 5
  • 2
0
votes
1 answer

Upload large file to API and store it ti blob

I have simple web api controller with action [HttpPost] public async Task Add(IFormFile file) { var firmware = await _firmwareManager.Add( new FirmwareAddDto { Name = file?.FileName, Version…
0
votes
0 answers

Is Dispose() disposing all child elements from platform renderer?

I added the IDisposable interface to one of my DatatTemplates and implemented the according methods. In the source code of a Plugin Dispose() is called on the View property of a UIViewController subclass. But the Dispose() method of my DataTemplate…
testing
  • 19,681
  • 50
  • 236
  • 417
0
votes
2 answers

How to dispose the data provider instance using HttpClient?

I have created my data provider using Repository Pattern. First, I designed a base repository interface as following: internal interface IGenericRepository { Task> GetManyAsync(); Task
amindomeniko
  • 417
  • 6
  • 23
0
votes
1 answer

Using or Dispose of SqlConnection not working, but Close does?

I have read the numerous posts on why you should give the using statement preference over manually doing .Open() then .Close() and finally .Dispose(). When I initially wrote my code, I had something like this: private static void doIt(string…
gotmike
  • 1,515
  • 4
  • 20
  • 44
0
votes
3 answers

Performing action when closing JFrame

In my program I have a main JFrame that holds a button. When this button is clicked a new JFrame appears in which I can change some information. Whenever I finish editing I press a save button on the new JFrame which saves the changes and disposes…
Simon
  • 174
  • 4
  • 18
0
votes
1 answer

How to apply using-pattern with System.Func?

Usually I use a memory stream with the well known using pattern. using(var mem = new MemoryStream(blob)) { foo(mem); } No imagine a function bar(Func) defined in a client library that I have to use. I could call it like this bar(() =>…
aggsol
  • 2,343
  • 1
  • 32
  • 49
0
votes
2 answers

How I safely dispose a variable?

What is an alternate/better way I can safely dispose of the variables purge and factory in the following code? public void Run( string XmlFragment ) { XmlNode xmlNode = null; try { …
M. Azam
  • 21
  • 4
0
votes
1 answer

Proper and Fastest way to dispose of a large form level object in C#

I understand the basics of using the Dispose/Finalize pattern and I do use it wherever I can but I seem to have a problem with this situation. I have a very small object: // Small Object public class Class1 { public int SampleId { get; set;…
Chad
  • 23
  • 2
0
votes
0 answers

JFrame.dispose(); isn't doing anything

I've tried every solution I could find here and on forums but I cannot close the wind JFrame no matter what I do and I have no idea why. I need to dispose of the JFrame and launch a different one by creating a WarioWareGUI object. Right now, the…
0
votes
1 answer

Process cannot access file because its used by another process

So I'm getting exception "Process cannot access file because its used by another process. The exception will show when i call this particular method: public async static Task DownloadFileFromFTP(string PathToFile, string AppName) { return…
Johny Corbie
  • 63
  • 10
0
votes
0 answers

Getting "invalid parameter" on assignment of new Bitmap() BEFORE disposing

I'm converting PDF-pages in small bitmaps for a DataGridView. I convert each page into a bitmap and assign it to a newly created bitmap inside a using() {}, like can be read in the code. I get an 'Invalid Parameter' as soon as I want to assign the…
Hespeet
  • 21
  • 3
0
votes
1 answer

C++/CLI Destructor not called when Dispose is called in C#

So I have a C++/CLI object held inside a C# object. I am calling dispose on my C++/CLI object and I have a breakpoints in both C++/CLI destructor and finalizer. I know that .NET should auto generate a Dispose for CLI objects and put the destructor…
user1289479
  • 291
  • 4
  • 16
0
votes
1 answer

How to stop observing old RxJava response statuses without dispose?

I have such case. User starts chain of request by clicking a button. Then he will make two photos uploading. However after starting uploading photos, he might return and start process over. My CompositeDisposable() is attached to the viewModel it…
Viktor Vostrikov
  • 1,322
  • 3
  • 19
  • 36
1 2 3
99
100