我们使用Titanium Mobile开发了一款应用。当我们首次在Android设备上运行应用程序时,它会使用大约25MB的内存。但每次我们使用设备后退按钮退出应用程序然后重新启动应用程序时,内存使用量会增加10MB。因此,如果我们退出并重新启动应用程序5次,应用程序最终会使用50MB的额外内存,总使用量为75MB。如果我们再次启动应用程序,应用程序将无法启动,并引发以下错误:
未捕获的错误:无法加载资源,Java异常是thrwon。 Source = assets.readAsset(assetPath);
我们最初认为这是我们的应用程序的问题,因此我们开发了一个简单的应用程序来测试该问题。这个测试应用程序只是创建一个窗口并为其添加标签。 app.js如下:
function createView() {
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
exitOnClose: true
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
win1.open();
}
createView();
嗯,测试应用程序与原始应用程序存在同样的问题。它首次启动时消耗14MB内存。 5次重启后(使用设备后退按钮),它消耗21MB(占初始内存的150%)。
我们还尝试过在Titanium中创建项目时生成的示例应用程序以及Titanium开发的Kitchen Sink应用程序。结果是一样的。
我们的测试是使用Titanium 3.0.0.GA和两个不同的设备完成的:
我们已经搜索了这个问题的解决方案但没有结果。我们不想相信这是Titanium的正常行为,因为如果是这样,Titanium根本不适合我们。有没有人为这个问题找到任何解决方案/解决方法?
提前致谢
更新:添加了测试应用程序的tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<id>com.cloudship.titanium.mobile.test</id>
<name>titanium-mobile-test</name>
<version>1.0</version>
<publisher>Javier</publisher>
<url>http://</url>
<description>not specified</description>
<copyright>2013 by Javier</copyright>
<icon>appicon.png</icon>
<persistent-wifi>false</persistent-wifi>
<prerendered-icon>false</prerendered-icon>
<statusbar-style>default</statusbar-style>
<statusbar-hidden>false</statusbar-hidden>
<fullscreen>false</fullscreen>
<navbar-hidden>true</navbar-hidden>
<analytics>true</analytics>
<guid>18e506f3-02d4-4fb7-84b7-ff8d4c1fac82</guid>
<property name="ti.ui.defaultunit" type="string">system</property>
<iphone>
<orientations device="iphone">
<orientation>Ti.UI.PORTRAIT</orientation>
</orientations>
<orientations device="ipad">
<orientation>Ti.UI.PORTRAIT</orientation>
<orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
<orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
<orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
</orientations>
</iphone>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:debuggable="true"/>
<supports-screens android:anyDensity="true"/>
</manifest>
</android>
<mobileweb>
<precache/>
<splash>
<enabled>true</enabled>
<inline-css-images>true</inline-css-images>
</splash>
<theme>default</theme>
</mobileweb>
<modules/>
<deployment-targets>
<target device="iphone">false</target>
<target device="ipad">false</target>
<target device="blackberry">false</target>
<target device="android">true</target>
<target device="mobileweb">false</target>
</deployment-targets>
<sdk-version>3.0.0.GA</sdk-version>
</ti:app>
答案 0 :(得分:1)
这是Titanium 3.0.0.GA中的一个错误。请参阅jira ticket here。幸运的是,它已在3.0.2中修复。
中给出了答案答案 1 :(得分:0)
我也正在开发Titanium。我检查了我的应用程序,我没有在HTC Desire上遇到Android 2.2.2上的这个问题。该应用已正确关闭。
您可以使用以下代码进行测试:
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
exitOnClose: true
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
win1.open();
所以删除周围的功能。
答案 2 :(得分:0)