objective-c - WebViews 不释放内存?

标签 objective-c cocoa memory-management webview automatic-ref-counting

好的,这是我的情况:

  • 我正在编写一个选项卡式应用程序(使用 PSMTabBarControl )。
  • 每个选项卡都包含一个 WebView (实际上是一个 MyDocument 实例,包含一个 WebView 子类 - 但应该没有太大区别)<
  • 我正在使用 ARC。

这就是问题:

  • 添加新选项卡(= 文档/ WebView )时,系统监视器中的内存会快速增加
  • 删除选项卡时,内存不会释放

发生什么事了?关于如何解决这个问题有什么想法吗?

<小时/>

如果您需要了解其他信息(例如具体代码),请告诉我。我正要开始用这个东西把头撞到墙上......

最佳答案

不知道怎么做,但这些东西对我有用,
在删除 WebView 时(当然,我只需要在应用程序关闭时执行一次),我正在调用 [webview close function] 请参阅文档,

/*!
    @method close
    @abstract Closes the receiver, unloading its web page and canceling any pending loads.
    Once the receiver has closed, it will no longer respond to requests or fire delegate methods.
    (However, the -close method itself may fire delegate methods.)
    @discussion A garbage collected application is required to call close when the receiver is no longer needed.
    The close method will be called automatically when the window or hostWindow closes and shouldCloseWithWindow returns YES.
    A non-garbage collected application can still call close, providing a convenient way to prevent receiver
    from doing any more loading and firing any future delegate methods.
*/
- (void)close;

/*!
    @method setShouldCloseWithWindow:
    @abstract Set whether the receiver closes when either it's window or hostWindow closes.
    @param close YES if the receiver should close when either it's window or hostWindow closes, otherwise NO.
*/

关于objective-c - WebViews 不释放内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14929987/

相关文章:

xcode - 如何让我的代码发现嵌入式实用程序?

java - JVM 崩溃并出现错误 ='Cannot allocate memory' (errno=12)

iphone - 关闭特定对象的控制台日志记录

css - Mac OS X WebKit 和 CSS 位置 :fixed scrolling

objective-c - 滑动但不点击

cocoa - 如何使用 NSArraycontroller 在 cocoa 上创建 NSFetchedresultController?

javascript - 你能找到分配给一个对象(node.js)的内存吗?

swift - 如何在 Swift 3 中将 UnsafePointer<[Float]> 或 Float Array 数据转换为 Unsafe[Mutable]Pointer<Float>?

iOS 8.1图像显示

objective-c - 在 Objective-C 中按值或按引用传递参数