gpt4 book ai didi

objective-c - WebViews 不释放内存?

转载 作者:行者123 更新时间:2023-12-03 17:35:00 25 4
gpt4 key购买 nike

好的,这是我的情况:

  • 我正在编写一个选项卡式应用程序(使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com