2016-01-26 63 views
0

我發現了一個內存錯誤,但應用程序不會崩潰,最後,我仍然可以使用它的錯誤後。Android的內存(最大調用堆棧大小超標)

我已經與主視圖中的應用程序,每次用戶打開另一個頁面,改變內容:

<Window> 
    <ScrollView id='menu'/> 
    <View id='content'/> 
</Window> 

而且更新這樣的內容:

var data, 
update = function(page) { 

    data.cleanup(); 
    data = null; 
    data = Alloy.createController('content/'page).getView(); 
    $.content.add(data); 
}; 

的爲例清理功能:

$.somepage.cleanup = function() { 

    data.button.removeEventListener('click',data.click); 
    for(var i in data.slides) data.slides[i].cleanup(); //widgets 
    data = args = null; 
}; 

這是我的錯誤得到:

[ERROR] : TiExceptionHandler: (main) [6643,90546] ----- Titanium Javascript Runtime Error ----- 
[ERROR] : TiExceptionHandler: (main) [0,90546] - In ti:/titanium.js:0,0 
[ERROR] : TiExceptionHandler: (main) [0,90546] - Message: Uncaught RangeError: Maximum call stack size exceeded 
[ERROR] : TiExceptionHandler: (main) [0,90546] - Source: (function (exports, require, module, __filename, __dirname, Titanium, Ti, glob 

,顯示了很多的時間在Appcelerator的控制檯的唯一的事情是跟蹤水平,那就是:

[TRACE] : TextView: stopSelectionActionMode() 

我每當我卸下控制器和時間增加可用內存功能添加一個新問題:

[INFO] : TiApplication: (main) [0,0] checkpoint, app created. 
[INFO] : TiApplication: (main) [162,162] Titanium 5.1.1 (2015/11/24 11:07 e46100b) 
[INFO] : Project built successfully in 3m 18s 95ms 
[INFO] : TiApplication: (main) [596,758] Titanium Javascript runtime: v8 
[WARN] : feature: [BMW]init phonw window 
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null 
[WARN] : V8Object: (KrollRuntimeThread) [187,187] Runtime disposed, cannot set property 'userAgent' 
[WARN] : linker: libti.paint.so has text relocations. This is wasting memory and prevents security hardening. Please fix. 
[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = [email protected] 
[INFO] : OpenGLRenderer: Initialized EGL, version 1.4 
[ERROR] : E/  : appName=pt.winsig.aktionserver.mobile.dev, acAppName=/system/bin/surfaceflinger 
[ERROR] : E/  : 0 
[INFO] : I/[MALI][Gralloc]: (in-house)open = 0xb5355bb9 
[INFO] : I/[MALI][Gralloc]: (in-house)close = 0xb5355c51 
[INFO] : I/[MALI][Gralloc]: (in-house)alloc = 0xb5355ea1 
[INFO] : I/[MALI][Gralloc]: (in-house)ref = 0xb5355ed1 
[INFO] : art: Background sticky concurrent mark sweep GC freed 2367(218KB) AllocSpace objects, 5(215KB) LOS objects, 3%% free, 22MB/23MB, paused 6.460ms total 18.772ms 
[INFO] : I/[MALI][Gralloc]: (in-house)unref = 0xb5355ef9 
[INFO] : I/[MALI][Gralloc]: gralloc tlcMemOpen recount = 0 
[INFO] : I/[MALI][Gralloc]: gralloc call tlcMemOpen 
[ERROR] : E/[MALI][Gralloc-ERROR]: void gralloc_private_TEEopen():946 tlcMemOpen fail, ret = -65536 
[INFO] : I/[MALI][Gralloc]: gralloc tlcMemOpen recount = 1 
[INFO] : MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0 
[INFO] : MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1 
[INFO] : MaliEGL: [Mali]max_allowed_dequeued_buffers=3 
[INFO] : APSAnalyticsService: Analytics Service Started 
[WARN] : APSAnalyticsService: Network unavailable, can't send analytics 
[INFO] : APSAnalyticsService: Stopping Analytics Service 
[ERROR] : function DisplayCaps() { [native code] } 
[WARN] : feature: [BMW]init phonw window 
[WARN] : art: Suspending all threads took: 6.111ms 
[INFO] : art: Background partial concurrent mark sweep GC freed 7928(381KB) AllocSpace objects, 4(1484KB) LOS objects, 17%% free, 18MB/22MB, paused 8.403ms total 87.589ms 
[WARN] : TiUIScrollView: (main) [3673,3673] Scroll direction could not be determined based on the provided view properties. Default VERTICAL scroll direction being used. Use the 'scrollType' property to explicitly set the scrolling direction. 
[INFO] : MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0 
[INFO] : MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1 
[INFO] : MaliEGL: [Mali]max_allowed_dequeued_buffers=3 
[INFO] : Choreographer: Skipped 40 frames! The application may be doing too much work on its main thread. 
[INFO] : APSAnalyticsService: Analytics Service Started 
[INFO] : APSAnalyticsService: Stopping Analytics Service 
[WARN] : APSAnalyticsService: Network unavailable, can't send analytics 
[INFO] : MEMORY BEFORE: 1298912 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 1292560 
[INFO] : MEMORY BEFORE: 509244 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 476780 
[INFO] : MEMORY BEFORE: 2706008 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 2639976 
[ERROR] : TiExceptionHandler: (main) [9580,89599] ----- Titanium Javascript Runtime Error ----- 
[ERROR] : TiExceptionHandler: (main) [1,89600] - In ti:/titanium.js:0,0 
[ERROR] : TiExceptionHandler: (main) [0,89600] - Message: Uncaught RangeError: Maximum call stack size exceeded 
[ERROR] : TiExceptionHandler: (main) [0,89600] - Source: (function (exports, require, module, __filename, __dirname, Titanium, Ti, glob 
[WARN] : feature: [BMW]init phonw window 
[ERROR] : V8Exception: Exception occurred at ti:/titanium.js:0: Uncaught RangeError: Maximum call stack size exceeded 
[ERROR] : V8Exception: RangeError: Maximum call stack size exceeded 
[INFO] : MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0 
[INFO] : MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1 
[INFO] : MaliEGL: [Mali]max_allowed_dequeued_buffers=3 
[ERROR] : libEGL: cache file failed CRC check 
[INFO] : MEMORY BEFORE: 376096 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 352352 
[INFO] : MEMORY BEFORE: 1823912 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 1554560 
[ERROR] : SQLiteLog: (284) automatic index on documents_lines(obrano) 
[INFO] : WebViewFactory: Loading com.google.android.webview version 47.0.2526.100 (code 252610000) 
[INFO] : cr_LibraryLoader: Time to load native libraries: 2 ms (timestamps 3478-3480) 
[INFO] : cr_LibraryLoader: Expected native library version number "47.0.2526.100", actual native library version number "47.0.2526.100" 
[INFO] : cr_LibraryLoader: Expected native library version number "47.0.2526.100", actual native library version number "47.0.2526.100" 
[INFO] : chromium: [INFO:library_loader_hooks.cc(122)] Chromium logging enabled: level = 0, default verbosity = 0 
[INFO] : cr_BrowserStartup: Initializing chromium process, singleProcess=true 
[ERROR] : SysUtils: ApplicationContext is null in ApplicationStatus 
[ERROR] : E/  : appName=pt.winsig.aktionserver.mobile.dev, acAppName=/system/bin/surfaceflinger 
[ERROR] : E/  : 0 
[INFO] : art: Background partial concurrent mark sweep GC freed 31679(1819KB) AllocSpace objects, 3(48KB) LOS objects, 13%% free, 25MB/29MB, paused 1.739ms total 105.475ms 
[WARN] : cr_media: Requires BLUETOOTH permission 
[ERROR] : WifiManager: mWifiServiceMessenger == null 
[INFO] : Choreographer: Skipped 35 frames! The application may be doing too much work on its main thread. 
[INFO] : MEMORY BEFORE: 1018608 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 710728 
[INFO] : MEMORY BEFORE: 1553480 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 1542872 
[INFO] : art: Background partial concurrent mark sweep GC freed 22703(1557KB) AllocSpace objects, 0(0B) LOS objects, 12%% free, 28MB/32MB, paused 1.792ms total 114.905ms 
[INFO] : MEMORY BEFORE: 1439904 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 1399504 
[INFO] : art: Background partial concurrent mark sweep GC freed 92433(4MB) AllocSpace objects, 12(756KB) LOS objects, 12%% free, 27MB/31MB, paused 1.681ms total 109.455ms 
[INFO] : MEMORY BEFORE: 597104 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 558848 
[INFO] : MEMORY BEFORE: 3212440 
[INFO] : controller check close 
[INFO] : controller check destroy 
[INFO] : controller run destroy 
[INFO] : controller check off 
[INFO] : controller run off 
[INFO] : MEMORY AFTER: 3168808 
[ERROR] : TiExceptionHandler: (main) [3687,145587] ----- Titanium Javascript Runtime Error ----- 
[ERROR] : TiExceptionHandler: (main) [0,145587] - In ti:/titanium.js:0,0 
[ERROR] : TiExceptionHandler: (main) [0,145587] - Message: Uncaught RangeError: Maximum call stack size exceeded 
[ERROR] : TiExceptionHandler: (main) [0,145587] - Source: (function (exports, require, module, __filename, __dirname, Titanium, Ti, glob 
[WARN] : feature: [BMW]init phonw window 
[ERROR] : V8Exception: Exception occurred at ti:/titanium.js:0: Uncaught RangeError: Maximum call stack size exceeded 
[ERROR] : V8Exception: RangeError: Maximum call stack size exceeded 
[INFO] : MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0 
[INFO] : MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1 
[INFO] : MaliEGL: [Mali]max_allowed_dequeued_buffers=3 
+0

爲什麼你不使用標籤?你對這個建築物有任何限制嗎? – Giordano

+0

這是大量的頁面和模塊,有時內容取決於一個id。 我認爲,通過這樣做,它會清除所有的前一頁的數據嗎? –

+0

主要問題更新:每當我卸下控制器,並添加新的和控制檯日誌的時間我已經添加了可用內存功能 –

回答

0

最大調用堆棧大小超過了是不是可用內存。

檢查here

我懷疑這是與Widget的功能cleanup()或一些錯誤,當你把它放在一個for循環不對勁。

+0

我在,這不是在iOS版追加了Android清理功能中的錯誤,之後圍繞代碼中的一些日子裏,我不得不重新創建功能。 –

+0

謝謝您的回答 –

1

您可以嘗試在您的清理功能添加幾行代碼:

// let Alloy clean up listeners to global collections for data-binding 
// always call it since it'll just be empty if there are none 
$.destroy(); 

// remove all event listeners on the controller 
$.off(); 

// remove any listeners you added to global proxies 
Ti.Gesture.removeEventListener('orientationchange', onOrientationChange); 

// and custom global dispatchers (all at once, via context) 
myDispatcher.off(null, null, $); 

// in turn, let controllers of required views clean up 
$.requiredView.cleanup(); 

// and close windows of controllers you created, triggering them to clean up as well 
someWindow.getView().close(); 

// this is not needed if someController cleans up well and we have the only reference 
// someController = null; 

我發現,在這篇文章中使用這些規則,我們來看一看:

http://www.tidev.io/2014/09/18/cleaning-up-alloy-controllers/

+0

我的清理功能是一樣的,但我只使用一個窗口。 –

+0

,我需要的合金控制器或合金每次小部件,這是我做的:。 'VAR的客戶= Alloy.createController(「客戶」)getView();' 比清理這樣的: '客戶.cleanup();' 這是一個控制器/微件的爲例: '$ .widget.name = args.name' '$ .widget.addEventListener( '點擊',somefunc);' '$ .widget.cleanup =函數(){'' $ .destroy();'' $ .off();'' $ .widget。removeEventListener(「點擊」,somefunc);'' = somefunc ARGS = NULL;'' };' –

+0

主要問題更新:每當我卸下控制器,並添加新的和時間我增加可用內存功能控制檯日誌 –

相關問題