0

I am using treemodel-js library for my program. When dealing with large json data file, my program crash throwing FATAL ERROR: JS Allocation failed - process out of memory.

when I am debugging my program, I found that execution of this line "var mmRoot = tree.parse(data);" is the cause of the problem. tree variable is TreeModel instance here.

Any ideas about this issue. It seems treemodel-JS having some problems in parsing large json file said hundreds of children in a tree

Nick Tang
  • 11
  • 2

1 Answers1

0

This is probably due to the fact that the parsing function is recursive and breadth first. That means that you will have a stack of function calls that grows to the size of your tree. That is one factor. The mergesort algorithm used is also recursive, so that might be another factor. If that's the case, there is not much you can do, except rewriting the traversal function in a non-recursive way... In any case, to make sure, you should post your json file, so this problem can be replicated. Alternatively you can also post an issue in the github repository.

user3743222
  • 18,345
  • 5
  • 69
  • 75
  • Note that the iterative version might come as slower as a trade-off : http://codereview.stackexchange.com/questions/47932/recursion-vs-iteration-of-tree-structure – user3743222 Nov 01 '15 at 03:55