2

Titanium Mobile を使用してアプリを開発しました。Android デバイスで最初にアプリを実行すると、約 25MB のメモリが使用されます。しかし、デバイスの [戻る] ボタンを使用してアプリを終了し、アプリを再起動するたびに、メモリ使用量が 10 MB 増加します。したがって、アプリを 5 回終了して再起動すると、アプリは 50MB の余分なメモリを使用することになり、合計で 75MB 使用されます。アプリをさらに数回起動すると、アプリは起動せず、次のエラーがスローされます。

不明なエラー: リソースの読み込みに失敗しました。Java 例外がスローされました。ソース = 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 アプリも試しました。結果は同じです。

私たちのテストは、2 つの異なるデバイスで Titanium 3.0.0.GA を使用して行われました。

  • HTC デザイア Z - Android 2.3
  • サムスンギャラクシー 2 - Android 4.0

この問題の解決策を検索しましたが、結果はありませんでした。これが 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>
4

3 に答える 3

1

これは Titanium 3.0.0.GA のバグです。jira チケットはこちら. 幸いなことに、3.0.2 で修正されました。

回答はチタン Q&Aで与えられました

于 2013-02-22T16:16:53.997 に答える
0

チタンも開発中です。アプリを確認しましたが、HTCDesireのAndroid2.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(); 

したがって、周囲の関数を削除します。

于 2013-02-22T12:19:50.007 に答える
0

これはメモリの問題の解決策です。このスレッドを通過してください

https://developer.appcelerator.com/question/116867/this-is-a-solution-to-your-memory-woes

于 2013-02-22T15:49:53.783 に答える