[英]i am trying to print a table in infinite loop in kotlin but getting this (Exception in thread "main" java.lang.OutOfMemoryError: Java heap space)
need help to resolve this error Exception in thread "main" java.lang.OutOfMemoryError: Java heap space需要帮助解决此错误 线程“主”java.lang.OutOfMemoryError: Java 堆空间中的异常
Fun main(){
Val num = 2
Var i = 1
while(i >= 1)
{
Println(num * i)
}
}
Well, it's fairly self-explanatory: you've run out of memory.嗯,这是不言自明的:你已经用完了 memory。
Value of i is always 1 and you are going in infinite loop so that's why out of memory is coming try to change the condition and you will get the output hope this helps i 的值始终为 1,您将进入无限循环,这就是为什么 memory 即将尝试更改条件,您将获得 output 希望这会有所帮助
Fun main(){
Val num = 2
Var i = 1
while(i >= 1)
{
Println(num * i)
i=i-1
}
}
Calling println
kicks off some internal operations that use memory, and if you spray a lot of them quickly enough, you can get an OOM (before garbage collection has a chance to run, I'm assuming)调用println
会启动一些使用 memory 的内部操作,如果你足够快地喷射大量它们,你可以获得 OOM(在垃圾收集有机会运行之前,我假设)
fun main() {
while (true) {
println("uh oh")
}
}
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.StringCoding$StringDecoder.decode (StringCoding.java:149)
at java.lang.StringCoding.decode (StringCoding.java:193)
at java.lang.StringCoding.decode (StringCoding.java:254)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.