PhoneGap垃圾收集 [英] PhoneGap Garbage Collection

查看:97
本文介绍了PhoneGap垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与我的朋友就PhoneGap进行了长时间的讨论。他说PhoneGap没有垃圾回收场景。我搜索了Javascript垃圾收集,并找到以下链接:



什么是JavaScript垃圾收集?





现在,这是一个问题:PhoneGap是否有垃圾回收器(或者PhoneGap应用程序已经像本机一样自动处理)?如果答案是肯定的,它是否类似于JavaScript垃圾收集器?



感谢您的评论:)

解决方案

在回答之前,我想澄清一点。没有适用于所有浏览器的全局JavaScript垃圾回收器,每个JavaScript实现都有不同的处理方法。虽然我猜想大多数实现都非常相似,但基于底层引擎,Firefox,Chrome,Safari等等垃圾收集的发生方式可能会有所不同。

PhoneGap应用程序本质上是一个专门的本地视图的包装,可以呈现HTML并运行JavaScript。对于Android,这是一个基于Android浏览器的WebView。对于iOS,这是一个使用Mobile Safari引擎的类似设置。每个平台都有自己的代码运行方式。



结合这两点,PhongGap不包含任何明确的垃圾回收,因为它已经在底层Web中实现发动机。 Android PhoneGap应用程序将使用Android Browser垃圾收集,iOS PhoneGap应用程序将使用Safari垃圾收集等。虽然您可以合理确定垃圾收集将与您的PhoneGap应用程序一起发生,但您可能会看到不同平台之间的结果。


I had a long discussion with my friend about PhoneGap. He said that PhoneGap has no garbage collection scenario. I searched for Javascript garbage collection and found the following links:

What is JavaScript garbage collection?

How to write low garbage real-time Javascript

Now this is the question: Does PhoneGap have garbage collector (or PhoneGap apps have been handled automatically like native ones)? If the answer is yes, is it similar to the javascript garbage collector?

I appreciate your comments :)

解决方案

Before the answer, I'd like to clarify a point. There isn't a global "JavaScript garbage collector" for all browsers, each JavaScript implementation has a different method for handling it. While I'd guess that most implementations are very similar, how garbage collection happens could differ between Firefox, Chrome, Safari, etc. based on the underlying engine.

A PhoneGap app is essentially a wrapper around a specialized native view that can render HTML and run JavaScript. For Android, this is a WebView, based on the Android Browser. For iOS, it's a similar setup which uses Mobile Safari's engine. Each platform will have its own way of running your code.

Marrying these two points, PhongGap doesn't contain any explicit garbage collection because it is already implemented in the underlying web engine. An Android PhoneGap Application will use Android Browser garbage collection, an iOS PhoneGap App will use Safari garbage collection, etc. While you can be reasonably certain that garbage collection will occur with your PhoneGap app, you may see different results between platforms.

这篇关于PhoneGap垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆