我可以/应该在 db4o 的复杂对象结构中使用 Wea​​kReference 吗?

发布于 2024-08-14 10:35:43 字数 335 浏览 3 评论 0原文

我正在考虑将应用程序移植到 db4o。数据模型由许多小对象组成,彼此之间有大量引用。例如,我有一本指向作者和章节的书。章节有章节,章节有大块的文本、图像,并且它们引用了提到的字符。

我认为应该可以将元结构保留在内存中(除了文本 blob 之外的所有内容),但我想知道是否可以使用一些涉及 WeakReference 的巧妙技巧,以便 db4o 只将我真正需要的模型部分保留在内存中(即我最近一直在使用的)。

对于文本 blob(应该在 1-10KB 左右)也是如此。是否有可能获得一个字符串,而不必担心数据库层,并且不必使用 getter 内的人工 ID 查询文本 blob,并且无需使用将整个文本始终保留在内存中的硬引用?

I'm considering to port an application to db4o. The data model consists of lots of small objects with a lot of references between each other. For example, I have a book which points to an author and chapter. Chapters have sections, sections have large blobs of text, images, and they reference characters mentioned.

I think it should be possible to keep the meta structure in memory (everything except the text blobs) but I was wondering whether I could use some clever trick involving WeakReference so db4o would just keep the part of the model in memory that I really need (i.e. which I've been using recently).

The same is true for the text blobs (which should be around 1-10KB). Is it possible to get a String without having to worry about the DB layer and without having to query for the text blob using an artificial ID inside the getter and without using a hard reference which keeps the whole text in memory all the time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半寸时光 2024-08-21 10:35:43

关闭 WeakReferences 主要用于性能调整。这种方法的缺点不可忽视——所以要小心。我不会推荐它。

应使用激活功能来控制内存使用。激活可以帮助您仅将部分模型保留在内存中,而弱引用将帮助您不再使用 GC 对象。我认为这就是要走的路。

另外 - 您可以将您的问题发布到 db4o 论坛,以从 db4o 社区获取帮助。

戈兰

Turning off WeakReferences is mostly used for performance tuning. The downsides to this approach are not negligible - so be careful. I would not recommend it.

Controlling memory usage should be done using activation features. Activation can help you keep only part of you model in memory and weakreferences will help you GC objects no longer used. I think that's the way to go.

Also - you can post your questions to db4o forums to get help from the db4o community.

Goran

天冷不及心凉 2024-08-21 10:35:43

我最近没有使用过 db40 或任何 ORM/OODB 产品,但是我突然意识到这种内存管理和内存管理是非常重要的。图形管理功能应该是框架本身的一部分,而不是您在框架之上构建的东西。如果 Versant 的 db40 不提供此功能,那么您可能值得考虑另一种提供此功能的产品。所以,我意识到这不是您正在寻找的答案,但利用该框架将是我的第一个停靠点。

I've not used db40, or any ORM/OODB product recently, however it would strike me that this kind of memory management & graph management feature should be part of the framework itself rather than something you build on top of it. If Versant's db40 doesn't offer this it might be worth you looking into another product instead that does offer it. So, I realise not the answer your looking for, but leveraging the framework would be my first port of call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文