Declined
Last Updated: 03 Sep 2025 06:30 by ADMIN
Michael D
Created on: 27 Aug 2025 15:53
Category: Data Source
Type: Bug Report
0
DataSource - Potential Memory Leak, because disposal is not possible

We have noticed that trees with a large number of items (or deeply nested trees) consume a large amount of memory. We use external dataSources that are passed via the tree's options.

After the tree is destroyed, only a small amount of memory is freed. The rest stays allocated. Recreating the tree several times adds additional allocated memory that never becomes available again.

As far as we've seen, the dataSource itself does not offer a destroy() method or anything similar to free its resources. Is there anything we need to do to destroy the dataSource?

1 comment
ADMIN
Martin
Posted on: 03 Sep 2025 06:30

Hello, Michael,

You are correct that the Kendo UI DataSource does not provide a built-in destroy() or disposal method to explicitly release its resources. This can result in memory not being fully reclaimed when destroying widgets like TreeView or TreeList that use external DataSources, especially with large or deeply nested data.

Current Recommendations

  • Remove References: After destroying the widget (e.g., TreeView or TreeList), ensure that you remove all references to the DataSource and any related data objects in your application. This allows the JavaScript garbage collector to reclaim memory if there are no lingering references.
  • Unbind Event Handlers: If you have attached event handlers to the DataSource (such as change, requestStart, etc.), manually unbind them before removing the DataSource:
    dataSource.unbind(); // Unbinds all event handlers
    
  • Clear Variables: Set the DataSource variable to null after destroying the widget and unbinding events:
    treeView.destroy();
    dataSource.unbind();
    dataSource = null;
    
  • Create New Instances: For each new widget instance, create a new DataSource instance and ensure all references to the old DataSource are cleared after destruction.

Following the above steps can help minimize memory usage, but a complete solution will require an explicit disposal mechanism in the DataSource itself.

If you need further optimization or have a specific scenario, please share more details about how your DataSource and widgets are managed in your application. I can then provide more targeted suggestions.

Regards,


Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.