Hibernate:持久化对象导致内存泄漏
我可能有一些设计理念错误。如果我有一个包含 10000 行的表意味着我将有 10000 个对象?
我问这个问题是因为我遇到了泄漏,并且使用 Jconsole 和 Eclipse MTA,它向我显示的唯一问题是一个 ArrayList,它似乎充满了从 Hibernate 检索的对象。
我应该增加堆大小吗?或者我应该做什么?
更新:该表反映了文件系统结构,目的是检索给定根的所有子项,因此我从 100 行(根文件夹)开始,然后搜索子项和孙项...
显然我不会工作同时与所有这些一起,想要类似“保留当前文件夹树并在切换根目录时杀死它”
I might have some design concept wrong. If I have a table with 10000 rows means I'll have 10000 Objects?
I ask because I got a leak, and using Jconsole and Eclipse MTA, the only problem it shows me is an ArrayList which seems to be filled with the Objects retrieved from Hibernate.
Should I just increase the heap size? or what I'm meant to be doing?
UPDATE: The table reflects a file system structure and the purpouse is to retrieve all the childs of a given root, so I start with 100 rows (root folders) and then search for childs and grandchilds...
Obviously I won't be working with all of them at the same time, would like something like "keep the current folder tree persisted and kill it when switch root"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您同时需要内存中的 10000 个对象,请增加堆大小。如果您需要全部 10000 个,但不一定同时需要,请重写代码以批量加载和处理它们。如果您只需要某些对象,请优化一些查询以仅加载您需要的内容。如果您需要更好的帮助,请更好地解释您的需求
If you need the 10000 objects in memory at the same time, then increase your heap size. If you need all 10000, but not necessarily at the same time, rewrite your code to load and process them in batches. If you only need some of the objects, optimize some queries to only load what you need. If you want better help, give a better explanation of your requirements