Click here to Skip to main content
15,895,880 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Thought of the Day Pin
peterkmx1-Oct-21 9:37
professionalpeterkmx1-Oct-21 9:37 
RantWeakReference broken in .NET5 Pin
Super Lloyd30-Sep-21 2:18
Super Lloyd30-Sep-21 2:18 
GeneralRe: WeakReference broken in .NET5 PinPopular
RickZeeland30-Sep-21 2:50
mveRickZeeland30-Sep-21 2:50 
GeneralRe: WeakReference broken in .NET5 Pin
Super Lloyd30-Sep-21 2:56
Super Lloyd30-Sep-21 2:56 
GeneralRe: WeakReference broken in .NET5 Pin
Richard Deeming30-Sep-21 4:17
mveRichard Deeming30-Sep-21 4:17 
GeneralRe: WeakReference broken in .NET5 Pin
honey the codewitch30-Sep-21 10:46
mvahoney the codewitch30-Sep-21 10:46 
GeneralRe: WeakReference broken in .NET5 Pin
Super Lloyd30-Sep-21 13:21
Super Lloyd30-Sep-21 13:21 
GeneralRe: WeakReference broken in .NET5 Pin
lmoelleb30-Sep-21 23:53
lmoelleb30-Sep-21 23:53 
For anyone wondering why... this is not because the release build is optimized - it is because extra IL is being injected into the debug build for debugging usability reasons.

If you have:
C#
{
  var thing1 = new thing1();
  // Do things to thing1
  var thing2 = new thing2(thing1);
  // Do things to thing2
  // "Breakpoint here"
}

On the breakpoint, you would expect to be able to see thing1. But as the garbage collector no longer see any reference to thing1 it can be collected as soon as the constructor of thing2 is done with it (the constructor does not even have to return).

To avoid this the compiler will inject IL to keep the variable "used" until he variable is out of scope seen from C# (or whatever language) - so the closing }.

Not sure how much "optimization" is really done in release. Maybe it is really just a "stop bloating" option - at least when I had to look I found release IL is a lot easier to read than debug IL Smile | :)
GeneralRe: WeakReference broken in .NET5 Pin
BillWoodruff30-Sep-21 22:22
professionalBillWoodruff30-Sep-21 22:22 
GeneralRe: WeakReference broken in .NET5 Pin
Super Lloyd30-Sep-21 23:29
Super Lloyd30-Sep-21 23:29 
GeneralRe: WeakReference broken in .NET5 Pin
Luca Leonardo Scorcia1-Oct-21 12:09
professionalLuca Leonardo Scorcia1-Oct-21 12:09 
GeneralRe: WeakReference broken in .NET5 Pin
Super Lloyd1-Oct-21 17:11
Super Lloyd1-Oct-21 17:11 
GeneralCCC 2021-09-30 Pin
jsc4229-Sep-21 22:04
professionaljsc4229-Sep-21 22:04 
GeneralRe: CCC 2021-09-30 Pin
OriginalGriff29-Sep-21 22:08
mveOriginalGriff29-Sep-21 22:08 
GeneralRe: CCC 2021-09-30 - Solved Pin
jsc4229-Sep-21 22:20
professionaljsc4229-Sep-21 22:20 
GeneralRe: CCC 2021-09-30 Pin
pkfox29-Sep-21 22:18
professionalpkfox29-Sep-21 22:18 
GeneralF-35 Pilot Helmet Pin
BernardIE531729-Sep-21 20:19
BernardIE531729-Sep-21 20:19 
GeneralRe: F-35 Pilot Helmet Pin
Kornfeld Eliyahu Peter29-Sep-21 20:35
professionalKornfeld Eliyahu Peter29-Sep-21 20:35 
GeneralRe: F-35 Pilot Helmet Pin
den2k8829-Sep-21 21:17
professionalden2k8829-Sep-21 21:17 
GeneralRe: F-35 Pilot Helmet Pin
snorkie30-Sep-21 2:42
professionalsnorkie30-Sep-21 2:42 
GeneralRe: F-35 Pilot Helmet Pin
Slow Eddie1-Oct-21 2:17
professionalSlow Eddie1-Oct-21 2:17 
GeneralRe: F-35 Pilot Helmet Pin
User 991608030-Sep-21 3:52
professionalUser 991608030-Sep-21 3:52 
GeneralRe: F-35 Pilot Helmet Pin
den2k8830-Sep-21 4:02
professionalden2k8830-Sep-21 4:02 
GeneralRe: F-35 Pilot Helmet Pin
dandy7230-Sep-21 5:47
dandy7230-Sep-21 5:47 
GeneralRe: F-35 Pilot Helmet Pin
Maximilien30-Sep-21 2:55
Maximilien30-Sep-21 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.