Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is unsafe C# garbage collected

I was reading about memory leaks in managed code and wondered if it was possible to create this in C# unsafe code?

unsafe
{
    while(true) new int; 
}

I wasn't sure if this would be caught by the GC if this was running as unsafe code?

Thanks

like image 381
Bali C Avatar asked Nov 11 '11 14:11

Bali C


1 Answers

The unsafe keyword just allows you to use unsafe code (pointers).

It doesn't change the semantics of ordinary code at all.

like image 132
SLaks Avatar answered Oct 04 '22 21:10

SLaks