gpt4 book ai didi

go - 如何避免golang中的堆栈溢出?

转载 作者:行者123 更新时间:2023-12-01 22:45:18 24 4
gpt4 key购买 nike

关闭。这个问题需要更多 focused .它目前不接受答案。












想改进这个问题?更新问题,使其仅关注一个问题 editing this post .

2年前关闭。




Improve this question




我在导出到 dll 时多次调用函数有问题。调用它,例如 80 000 次会导致堆栈溢出。有什么办法可以避免吗?我可以在函数调用后清除堆栈或堆吗?

//export GetNum
func GetNum(DeviceType uint32, DeviceInd uint32, CANInd uint32) int {
return 0
}

最佳答案

Calling it e.g 80 000 times cause stack overflow. Is there any way to avoid it?



是的,例如只需调用 10'000 次。或者不要使用递归算法或将递归转换为正常循环(尾调用优化)。

附言您的代码未显示任何相关详细信息。

关于go - 如何避免golang中的堆栈溢出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58520295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com