this post was submitted on 16 Dec 2025
9 points (100.0% liked)
C Sharp
1749 readers
5 users here now
A community about the C# programming language
Getting started
Useful resources
- C# documentation
- C# Language Reference
- C# Programming Guide
- C# Coding Conventions
- .NET Framework Reference Source Code
IDEs and code editors
- Visual Studio (Windows/Mac)
- Rider (Windows/Mac/Linux)
- Visual Studio Code (Windows/Mac/Linux)
Tools
Rules
- Rule 1: Follow Lemmy rules
- Rule 2: Be excellent to each other, no hostility towards users for any reason
- Rule 3: No spam of tools/companies/advertisements
Related communities
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Far more familiar with Java since I've mostly used that the last decade, but two questions come to mind...
At least GC.Collect() is a blocking collect, but perhaps there could also be funky shenanigans happening? I'd also think it'd collect obj1, but it is still in the same scope it was created in. Maybe there could also be some funkyness there with objects only getting picked up if they're out of scope or similar?
I'd imagine most of the above would be really easy to test if you can get a debugger to step through. If it doesn't hit at all, something odd is happening with flagging the objects for collection I'd think. If it hits but errors, easy peasy. If it hits and executes fine but doesn't show, maybe as others suggested, use a different function rather than something from Console or something?