私は現在、少なくとも1つのパラメータがfalseである限り、ベース計算ループが再帰呼び出しで繰り返し実行されるいくつかの科学計算を行っています。第九百十五再帰関数呼び出し -同じ操作でnodejの関数呼び出しが制限されていますか?
現在、私のnodejsサーバは約905で停止します。
奇妙なことは、それがすべてのエラーをクラッシュ、また出力しないこと、です。それだけで何もして停止しない - >これ以上のログなど
がオーバーフローを避けるために、ノードからいくつかの保護動作このですか?
私はできるだけインテリジェントなソフトウェアと「ループ」を制限しようとしながら、ここ数週間のためにこれに苦しんでいます。
はあなたの助け&アドバイスをいただき、ありがとうございます。 ご挨拶Noa。
要求されたとして、私は、私はこれが役に立てば幸い私の実際のコード
のいくつかの抽象化を提供します。 1.5k以上の回線で構成されているため、オリジナルのコードをここに置くことはできません。 しかし、以下の例では、再帰呼び出しの背後にある基本ロジックについて説明します。
// Contains objects which contain an array
// which represents the amount of the ex_obj terms
var amount = {
a:[10,10],
b:[7.5,7.5],
c:[2.5,2.5,2.5,2.5]
}
// Contains objects, which contain an array of other objects
// that represent some selection
// Each object in an array consists of different values per attribute per 1 amount
var ex_obj = {
a: [
{aa: 1.41, ab: 0.143, ac: 0.5},
{aa: 1.30, ab: 1.43, ac: 0.42}
],
b: [
{aa: 0.32, ab: 5.54, ac: 1.3},
{aa: 0.33, ab: 4.49, ac: 2.5}
],
c: [
{aa: 0.54, ab: 1.4, ac: 3.5},
{aa: 0.39, ab: 1.434, ac: 3.91},
{aa: 0.231, ab: 1.44324, ac: 2.91},
{aa: 0.659, ab: 1.554, ac: 3.9124},
]
}
// Here we have an object that represents
// the "to be" state which should be achieved
var should_be ={
aa: 14.534,
ab: 3.43,
ac: 5.534
}
function calculate(){
// Now we want to mulitply the amount object values with
// the ex_obj values
for(let prop in ex_obj){
for(let i = 0, i < ex_obj[prop].length, i++){
for(let propa in ex_obj[prop][i]){
// here every aa,ab,ac gets mulitplied with the
// contains of the amount obj for the matching
// propertyname
}
}
}
// the next step is to check if the sum of all ex_obj property
// child values per aa, ab and ac match the should_be propertie values
// if everything is above the should_be and not too high then the
// programm can stop here and print out the amount obj.
// if the sum of the ex_obj properties is too little
// compared to the should_be obj
// we need to check which property is too little
// e.g. aa is too little
// then we check where aa in the ex_obj per 1 value is
// the highest
// then we increment the matching amount property child
// and start calculate() again
// same procedure for - if something is too much
}
ノードは、再帰呼び出しを非同期呼び出しで置き換え、スタックの成長を完全に避けることは比較的簡単です。詳細とサンプルコードを提供してください... – Amit
私は、コードを見ることなくあなたを助けることができると疑う。スタックオーバーフローは、実際のコードを含む質問ではうまくいくが、コードなしの概念的な質問ではうまくいかない。 – jfriend00
私は質問を更新しました –