如何从mysql数据库的arraylist中添加超过50,000,000条记录 [英] How to add more than 50,000,000 records in arraylist from mysql database
问题描述
从数据库中将超过50,000,000条记录添加到数组列表中.我要添加30,000,000条记录,显示堆内存不足错误.
Add into array list more than 50,000,000 records from data base. I am adding 30,000,000 records it showing out of heap memory error .
推荐答案
在这里看看:增加Java中的堆大小
您可以在JVM上设置标志以增加堆大小.使用任何您想使用的东西,但请确保您显然有RAM.
You can set a flag on the JVM to increase the heap size. Use whatever you want but be sure you have the RAM obviously.
从命令行:
java -Xmx8g myprogram
java -Xmx16g myprogram
或者,如果您知道程序需要多少空间,请设置初始堆大小:
Or if you know how much space your program needs, set the initial heap size:
java -Xms4g myprogram
请谨慎使用.正如其他人所评论的那样,这比Java堆的默认限制更可能是您的方法出现的问题.
Use these cautiously. As others have commented, this is more likely a problem with your approach than the default limit of the Java heap.
这篇关于如何从mysql数据库的arraylist中添加超过50,000,000条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!