Big Tree:何时在RIA中发布数据

时间:2022-06-06 12:37:44

This question is about a Java JTree or a Window .Net Tree (Winforms) or an Adobe Flex Tree.

这个问题是关于Java JTree或Window .Net Tree(Winforms)或Adobe Flex Tree。

In a client-server application (for Flex it's Web, really), I have a tree with hierarchical data (in a Windows Explorer type interface). Right now I lazily load up the tree as the user requests more data from the server. This is fine and will work up to about 750K nodes (empirically tested on .Net Winforms and Adobe Flex), but after that it gets sluggish. But the databases grow fast (mostly because users can paste in huge amounts of nodes) and a database of 20 million nodes is not at all unlikely.

在客户端 - 服务器应用程序(实际上是Flex的Web)中,我有一个带有分层数据的树(在Windows资源管理器类型的界面中)。现在,当用户从服务器请求更多数据时,我懒得加载树。这很好,可以工作到大约750K节点(通过.Net Winforms和Adobe Flex进行经验测试),但之后它变得迟缓。但是数据库增长很快(主要是因为用户可以粘贴大量节点),而且一个拥有2000万个节点的数据库根本不可能。

Should I be releasing data from the tree when a branch is collapsed so the Garbage Collector can release the memory? This is fine, but what if the users are not efficient and don't collapse branches? Should I do a memory management module that goes around closing branches that haven't been touched in a while?

折叠分支时,我是否应该从树中释放数据,以便垃圾收集器可以释放内存?这很好,但如果用户效率不高并且不折叠分支怎么办?我应该做一个内存管理模块,绕过关闭一段时间没有触及的分支吗?

This all seems like a lot of work so as not to not run out of memory.

这一切似乎都是很多工作,以免不会耗尽内存。

Edit: Should I release data on node collapse? If so, when? The weak-object cache idea is good, but should I just continue filling up the UI until it busts (maybe it's not a bad idea)?

编辑:我应该在节点崩溃时发布数据吗?如果是的话,何时?弱对象缓存的想法很好,但是我应该继续填充UI直到它破灭(也许这不是一个坏主意)?

2 个解决方案

#1


1  

If the users don't collapse branches, then I guess they're going to be scrolling through 750K to 20M nodes, right? Seems rather inefficient to me from a user POV. So, the problem may well be self-enforcing.

如果用户没有折叠分支,那么我猜他们将要滚动750K到20M节点,对吧?对于我来说,用户POV似乎效率低下。所以,问题可能是自我实施。

#2


1  

in most frameworks i've seen, the tree structure itself is fairly efficient, but if you have a non-trivial object at each tree leaf it quickly adds.

在我看过的大多数框架中,树结构本身相当高效,但如果你在每个树叶上都有一个非平凡的对象,它会很快添加。

the easiest would be not to store anything at the tree leaves, but on the render/draw/update/whatever method, pick your object from a weak-ref cache. if it's not there, load from the server. the trick is not to keep any other reference to the object, only the weak one on the cache. that way, it will be still available, but collected when necessary.

最简单的不是在树叶上存储任何东西,而是在渲染/绘制/更新/任何方法上,从弱参考缓存中选择你的对象。如果不存在,请从服务器加载。诀窍是不保留对象的任何其他引用,只保留缓存中的弱引用。这样,它仍然可用,但在必要时收集。

#1


1  

If the users don't collapse branches, then I guess they're going to be scrolling through 750K to 20M nodes, right? Seems rather inefficient to me from a user POV. So, the problem may well be self-enforcing.

如果用户没有折叠分支,那么我猜他们将要滚动750K到20M节点,对吧?对于我来说,用户POV似乎效率低下。所以,问题可能是自我实施。

#2


1  

in most frameworks i've seen, the tree structure itself is fairly efficient, but if you have a non-trivial object at each tree leaf it quickly adds.

在我看过的大多数框架中,树结构本身相当高效,但如果你在每个树叶上都有一个非平凡的对象,它会很快添加。

the easiest would be not to store anything at the tree leaves, but on the render/draw/update/whatever method, pick your object from a weak-ref cache. if it's not there, load from the server. the trick is not to keep any other reference to the object, only the weak one on the cache. that way, it will be still available, but collected when necessary.

最简单的不是在树叶上存储任何东西,而是在渲染/绘制/更新/任何方法上,从弱参考缓存中选择你的对象。如果不存在,请从服务器加载。诀窍是不保留对象的任何其他引用,只保留缓存中的弱引用。这样,它仍然可用,但在必要时收集。