- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
.NET and destructors!!!!!!!!!!!!!
Collapse
X
-
-
-
Same as in .net. The garbage collector will decide when to call the destructor. At least, you can write one.Originally posted by JabberwockyJust use Java and get your garbage collected.
.Net! The best! The future!I've seen much of the rest of the world. It is brutal and cruel and dark, Rome is the light.Comment
-
Comment
-
You can in Java too. You override the finalize() method from the Object class. Though as in .NET, the garbage collector has a mind of its own and will garbage collect when it feels like it.Originally posted by FranckoSame as in .net. The garbage collector will decide when to call the destructor. At least, you can write one.Comment
-
Comment
-
And you have to move your object references to the end of yer driveway or else theyll be left there for days....
Ok, I admit, its time to get out of IT...
Vieze Oude Man
Comment
-
Except when they're on strike.Originally posted by FungusOur garbage collector comes round once a week. We have to put recyclables in the green bin.
I think I want my objects destroyed when I bloody well tell them to be destroyed.
Will work inside IR35. Or for food.Comment
-
You said it - I can agree with GC deciding when to collect garbage, however if I call GC.Collect() this means it MUST collect, or at least not to keep classes with destructors hanging for a long time - the funny thing is that happens only in SOME circumstances in .NET 1.1, but seems to happen full time in .NET 2.0Originally posted by VectraManI think I want my objects destroyed when I bloody well tell them to be destroyed.
Yes I started using IDisposable for a long time, but I also had destructor - this was the undoing as GC seems to have queued them for destruction in a separate thread that was taking AGES to execute under some circumstances that I managed to re-create.Originally posted by cswdMake sure they implement IDisposable and stick them in using blocks.
Highly annoying memory "leak" was fixed by commenting out destructors, I mean this is BS! Can't always use "using" block since I need to have many objects that will self-destruct when needed.
Comment
-
Which was exactly the problem - I had Dispose called for all objects, but they were not removed from heap because objects had consturctors, so GC in its wisdom thought to keep them around since it assumed that just because machine has got 2 GB of RAM its okay to eat 300 MB of it for no reason - crap GC design. If programmer explicitly calls GC.Collect() then GC should either collect garbage or new developer responsible for GC should be hired.Originally posted by cswdThe object should have finished it's work when you've finished with it and released it for destruction. The only thing it should do is free the heap later (all stack stuff is freed during execution).
I don't like solutions like this - this problem in GC was responsible for another strange memory leak that I had - starting at 300 MB but working its way to 1.5 GB until it run out of memory, effectively it seemed that GC stopped workingOriginally posted by cswdIf that fails, stick 12Gb of memory in the machine (I've had to do this before!). Plenty of room for the GC to fill up.
Comment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers

Comment