将记录写入 Berkeley DB 时出现问题
当我写入 1033 条记录时,它写入成功,但是当我写入 5,00,000 条记录时,它给出以下错误
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at WriteDataUsingCursor.main(WriteDataUsingCursor.java:31)
when i am writing 1033 record then it write successfully but when i am writing 5,00,000 record the it give following error
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.split(Unknown Source)
at java.lang.String.split(Unknown Source)
at WriteDataUsingCursor.main(WriteDataUsingCursor.java:31)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
权宜之计是增加堆大小;请参阅“如何增加 JVM 内存”。
但是,您可能想了解应用程序内存不足的原因。它可能会保留部分或全部数据的内存,这可能是问题的真正原因。追踪此类问题的一般方法是使用内存分析器来找出它使用大量内存的原因。
The band-aid solution is to increase the heap size; see "How can I increase the JVM memory".
However, you may want to look into why your application is running out of memory. It may be keeping an in-memory of some or all of the data, and that may be the real cause of your problems. The general approach to tracking down this kind of problem is to use a memory profiler to figure our why it is using a lot of memory.
我认为您遇到这个问题是因为您使用的是嵌入式数据库,并且这些数据库通常在您有少量值时使用,如果您需要输入大量值,我建议使用 sql server 或 oracle 11g
i think you are having this problem because you are using an embedded database and those are normally used when you have a small number of values, i would suggest using sql server or oracle 11g if you need to enter alot of values