Questions tagged [unmanagedresources]

67 questions
1
vote
1 answer

What happens if i do not dispose unmanaged resources after the program is closed

So I heard from someone that it simply never releases, but what does it mean? Even if you close the program it stays in memory? How is that happening? Couldn't find an answer for that, if this is duplicated or not good enough Q for the forum please…
omriman12
  • 1,644
  • 7
  • 25
  • 48
1
vote
2 answers

Unmanaged C code in C# Marshalling by ref string array!

I am having a really hard time getting this marshalling down. I have umanaged code that looks like this: WORD HLP_GetDeviceNames (LPSTR *DevNames, WORD Max_Len, WORD Max_Num) Just FYI I did not write this unmanaged code but must use it. Returns:…
Mike Bynum
  • 763
  • 2
  • 10
  • 22
1
vote
1 answer

sbt: copy resources to classpath in multi project build

I have a sbt project with following structure: project | |-- file.json |-- |-- project aggregates both serverProject and clientProject. Starting sbt and compiling works fine. When running or packaging serverProject…
Kristof
  • 51
  • 6
1
vote
1 answer

Should Marshal.FreeHGlobal be Called or LocalFree?

Seen a piece of code which I'm not sure whether I need to release memory. If I have this block below: IntPtr buf = new IntPtr(logRecord.ToInt32() + logTotalCount * Marshal.SizeOf(typeof(SomeUnmanagedStruct))); Do I need to call…
AshesToAshes
  • 937
  • 3
  • 14
  • 31
1
vote
1 answer

Should I use CloseHandle on a locally defined IntPtr variable?

If I use this... [DllImport("kernel32.dll")] static extern IntPtr GetConsoleWindow(); ...to get the instance of the console in my C# .Net4.5 Console app and assign it to a variable (which I pass as the hWnd parameter in a call to user32's…
Riegardt Steyn
  • 5,431
  • 2
  • 34
  • 49
1
vote
2 answers

Wpf managed resources cleanup

I'm trying to find a good way of cleaning up unmanaged resources that my custom controls may generate. The scenario is in which the parent window opens a child window that has a custom control with unmanaged resources (see code below). These…
pastillman
  • 1,104
  • 2
  • 16
  • 27
1
vote
1 answer

Are the database-related objects such as connection object, command object, datareader, dataadapter,... unmanaged resources?

Are the database-related objects such as connection object, command object, datareader, dataadapter,... unmanaged resources?
odiseh
  • 25,407
  • 33
  • 108
  • 151
1
vote
1 answer

How to destroy ICONINFO?

I step through the code and look in Task Manager the number of GDI and user objects used by the process. Tracked the number of objects in the code I wrote in the comments. I noticed that after performing the following code remains one unreleased…
Anatolii Humennyi
  • 1,807
  • 3
  • 26
  • 37
1
vote
1 answer

Do ToolStripMenuItem have any underlying unmanaged resource?

I use ToolStripMenuItem inside some of my projects and allocate it using C# operator new: ToolStripMenuItem someMenuItem = new ToolStripMenuItem("Some Item"); I read MSDN documentation on IDisposable interface and using statement…
VirtualVDX
  • 2,231
  • 1
  • 13
  • 14
1
vote
2 answers

Differences between these two implementations using the using-keyword

Just for an example of creating a MD5 hash, microsoft provided this code sample: MSDN Code // in Helpers class public static string GetMd5Hash(MD5 md5Hash, string input) { byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); …
Michael Schnerring
  • 3,584
  • 4
  • 23
  • 53
0
votes
5 answers

List of cases where USING statement should be employed

"File and Font are examples of managed types that access unmanaged resources (in this case file handles and device contexts). There are many other kinds of unmanaged resources and class library types that encapsulate them. All such types must…
Compunick
0
votes
1 answer

Is there some standard way to explicitly close services and other resources?

For instance when using database connection, threading or IO streams (all what is required explicit closing/free up) is there some standard way of doing this? Perhaps by implementing some standard interface so Framework/class consumer would be able…
sll
  • 61,540
  • 22
  • 104
  • 156
0
votes
1 answer

Releasing COM-Object not necessary?

So with _excel = New Excel.Application if im not using _excel.Quit and FinalReleaseComObject(_excel), when my application closes, the excel process will close too. On the other hand when I use both cleanup methods, excel process will stay until my…
user17611369
0
votes
0 answers

Examples of unmanaged resources when to implement Dispose pattern in C#

.NET documentation states when the dispose pattern is supposed to be used. It is when we interact with: file handles pipe handles registry handles wait handles pointers to blocks of unmanaged memory What are some practical C# examples of each…
Patrik Mihalčin
  • 3,341
  • 7
  • 33
  • 68
0
votes
1 answer

Does GC.SupressFinalizer() prevent GC from collecting the managed resources?

If Finalizer (destructor) is implemented in a class and GC.SupressFinalizer() is called from the overriden Dispose() method will the Garbage Collector still take care of any managed resources the instances of that class might have? What confuses me…