Fenix 3 app crash and device restart

Former Member
Former Member

I have been working on a program that reads a string and converts it to an array of words. For example, "This is a test sentence" should get converted to ["This", "is", "a", "test", "sentence"].

Because my app has to do this with strings that can contain a large number of words I tried to optimize the program: Instead of using list.add, which is very expensive, to add a word to the array I am using a linked list. For some reason my fenix 3 crashes when the number of words is greater than 37.

This is the minimal code to reproduce the crash:

function makeLinkedList() {
    	var n = 37; // crash at 37 or more
    	var start = new LL();
    	var object = start;
    	object.content = 0;
    	for (var i = 1; i < n; i++) {
    		object.next = new LL();
    		object = object.next;
    		object.content = i;
    	}
    	
    	var ret = new [n];
    	object = start;
//    	start = null; adding this line prevents crash for some reason
    	for (var i = 0; i < n; i++) {
    		ret[i] = object.content;
    		var n = object.next;
    		object = n;
    	}
    	return ret;
    }

and this is my LinkedListElement class:

class LL {
	var content;
	var next;
}

I have no clue what is the problem, it seems like it has something to do with too many recursive objects. I do not know if this only affects the fenix 3 because everything works well in the simulater.