本文介绍了是垃圾收集用于生产质量Cocoa应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主要想知道垃圾收集对性能的影响。



我可以想到的另一个问题是使用垃圾回收可能导致sloppier编程。



您是否在应用中使用垃圾回收?

解决方案

垃圾回收生产质量应用。 Xcode,Automator,System Preferences和其他几个系统应用程序是GC'd,你可以预期这种趋势会随着时间的推移而持续。



同样,许多开发人员已经接受GC并专门在其应用中使用它。例如,Intuit的Mac版Quicken和QuickBooks的新版本是垃圾回收的。



GC也有很多优点。从我的头顶和个人经验:




  • 它使多线程更容易;一个简单的assign是所有权的一个原子声明


  • 它将一堆内存管理卸载到其他内核;它自然是并发的,并且从主线程(或计算线程)卸载一个计算。

  • 在许多情况下,分配和释放可以完全在上下文一个线程,因此消除了对全局同步或锁定的任何需求


  • 收集器在每个版本的Mac OS X上运行得更快,它与系统的其余部分)。通过将更多应用程序的计算负载卸载到系统提供的框架,您的应用程序将从优化到底层系统获得越来越多。


  • 对象图的亲密知识 - 对象之间的指针 - 在内存中,它使分析和调试显着更容易。而不是这个悬挂指针从哪里来的?,现在的问题是给我一个列表,为什么这个对象比我认为应该停留更长的时间。




这不是说没有工作要做,使您的应用程序在GC下的最佳工作。肯定有这样的任务!


I'm mainly wondering about the affect that garbage collection would have on performance. Is the use of garbage collection frowned upon for release apps?

Another concern that I can think of is that using garbage collection could lead to sloppier programming.

Do you use garbage collection in your apps?

解决方案

Garbage Collection is used in many production quality applications. Xcode, Automator, System Preferences and several other system applications are GC'd, and you can expect that trend to continue over time.

As well, many developers have embraced GC and are using it exclusively in their applications. Intuit's new versions of Quicken and QuickBooks for the Mac are garbage collected, for example.

There are a number of advantages of GC, too. Off the top of my head and from personal experience:

  • it makes multithreading easier; a simple assign is an atomic declaration of ownership

  • it offloads a bunch of memory management to other cores; it is naturally concurrent and offloads a bunch computation from the main thread (or computation threads)

  • in many cases, allocation and deallocation can happen entirely within the context of a thread, thus eliminating any need for global synchronization or locking

  • the collector has gotten faster with each release of Mac OS X and that trend will continue (just as it has with the rest of the system). By offloading more of your app's computational load to the system provided frameworks, your app will gain more and more from optimizations to the underlying system.

  • because the collector has intimate knowledge of the object graph -- of the pointers between objects -- in memory, it makes analysis and debugging significantly easier. Instead of "where did this dangling pointer come from?", the question is now "Give me a list of reasons why this object is sticking around longer than I think it should?".

This isn't to say that there isn't work to do to make your application work optimally under GC. There certainly are such tasks!

这篇关于是垃圾收集用于生产质量Cocoa应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 23:20