Skip to content

Ghost objects issue on data change/update #4480

@Havock94

Description

@Havock94

Hi,
I found an issue while updating my data source in the grid.
We're using a complex data binding, our object is composed from a SQL query and to explain it easily, our data array is the array of the records given from the DB. Due to the complexity is also pretty hard to create a Plnkr and replicate the issue.

The problem is caused when a search is made on the DB and it returns the new array of records that is bound to the grid.
With the help of the Chrome profiler we've seen this:

  • 1000 records loaded at the beginning
    (executed a search on the DB (returned 177 records))
  • 999 records deleted
  • 177 records added

As you can see exactly ONE record stayed in memory.
Decreasing the number of starting records we've found out that this happens when there are more than 20 records loaded (our grid shows 10 rows so we've tought about an internal caching that stores a number of object doubled respect the ones shown, but we might be wrong).

This ghost record causes Angular to throw some errors, because it tries to read a property that doesn't exist (the record is actually deleted so the one that the grid stores is a fake record) and the errors are thrown (probably) until the next Angular digest. With the new digest it looks like the Grid picks up the correct records and no more errors are thrown.

The same test were made with Angular ngRepeat and there were no surprises there.

  • 1000 records at the beginning
  • 1000 records removed
  • 177 records added

We've tried to set gridOptions.data.length to 0 before the search query to completely clear it so we could fill it up after the response but it didn't work.

So we would like to know how to proceed, what's the correct way to completely unbind a data array from the grid so that we can bind a new one? Do you have any clue for the ghost record that isn't deleted? May it cause memory leak?

Thank you for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions