在浏览器中增加堆栈大小 [英] Increasing stack size in browsers

查看:185
本文介绍了在浏览器中增加堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简短的问题:我有一个在递归方面很深入的javascript.如何增加堆栈大小以便执行(在Unix系统中类似于"ulimit -s unlimited")?

Short question: I have a javascript that goes very deep in recursion. How can I increase the stack size so that I can execute it (something like "ulimit -s unlimited" in Unix systems)?

长话短说:我必须画一个图,然后使用Cytoscape JS( http://js.cytoscape.org/)与Dagre布局扩展名( https://github.com/cytoscape/cytoscape .js-dagre ).绘制算法在递归中进行得很深入,最终我在Chrome中遇到"Uncaught RangeError:超出最大调用堆栈大小"的问题,而在Firefox中则得到了太多的递归"问题.如何将堆栈大小设置为无限制或很大(例如,在Unix系统中为"ulimit -s unlimited"),以便绘制图形?

Long story: I have to draw a graph and I use Cytoscape JS (http://js.cytoscape.org/) coupled with the Dagre layout extension (https://github.com/cytoscape/cytoscape.js-dagre). The drawing algorithm goes deep in the recursion and I end up getting "Uncaught RangeError: Maximum call stack size exceeded" in Chrome and "too much recursion" in Firefox. How can I set the stack size to unlimited or very large (i.e. like "ulimit -s unlimited" in Unix systems) so that I can draw the graph?

谢谢!

推荐答案

您不能在浏览器中更改堆栈大小,但是可以使用名为

You cannot alter the stack size in browsers, but you can use a trick called trampolining.

您可以在此处找到有效的代码解决方案:

You can find a working code solution here:

如何在JavaScript中理解蹦床?

这篇关于在浏览器中增加堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆