is there any disadvantage other than performance issues.....??????
Thanks
is there any disadvantage other than performance issues.....??????
Thanks
Performance is the main consideration. Garbage Collection (along with any other automatic memory technique, like autorelease) must be, by definition, slower than manually managing memory since the processor must actually deal with memory management expressly, at runtime, versus you dealing with it at compile time.
The only other significant downside is that garbage collection lends itself only to code where you can accept that you must persist objects through references, and that, if not persisted, those objects CANNOT be restored, even if they continue to exist, since their existence cannot be determined. This is, in general, not difficult, but their are some problems, often involving multi-threading, for which this makes writing algorithms difficult, as references to objects may be difficult or impossible to persist within a scope. Also, with GC, you don't necessarily know when your objects are being destroyed, thus destructors are almost useless.
Lastly, garbage collection works better in managed memory environments than in direct access environments, for obvious reasons.
In general, garbage collection's disadvantage in performance is often negligible, especially considering the power of modern machines, and the security and ease of coding it offers are more often than not well worth the cost. GC can be optimized, as well, by doing things like explicitly calling it when you know you are not busy, and by using multi-stage collectors, which both OSX and .Net do natively.