-
Bug
-
Resolution: Unresolved
-
Normal
-
None
-
6.5.4
When removing a binding set in org.zkoss.zkplus.databind.DataBinder and derived classes by calling removeBinding(..), the respective BindingNode is not removed from _beanSameNodes, resulting in references to components (which may have been detached already) hanging in memory, without any option to clean this up (except hacking oneself into the private field using reflection, which I would consider very dirty). Ultimately, an application can crash by running out of memory.
Proposed fix:
public void removeBinding(Component comp, String attr) {
Binding binding = super.getBinding(comp, attr); // we need this for cleanup
super.removeBinding(comp, attr);
if (binding != null) {
// clean any leaks within _beanSameNodes if required
if (_beanSameNodes != null) {
for (Iterator<Set<Object>> it = _beanSameNodes.values().iterator(); it.hasNext() {
Set<Object> value = it.next();
if (value != null) {
for (Iterator<Object> it1 = value.iterator(); it1.hasNext() {
Object entry = it1.next();
if (entry instanceof BindingNode)
}
}
}
}
}
}
/package/ static void cleanBindingNode(BindingNode bindingNode, Binding binding) {
LinkedHashSet<Binding> bindings = bindingNode.getBindings();
bindings.remove(binding);
Collection<BindingNode> kidNodes = bindingNode.getKidNodes();
for (Iterator<BindingNode> it = kidNodes.iterator(); it.hasNext()
}