By assigning the Data
property like you did duplicates the records. You have now two different isntances of TClientDataset
with two different set of records with precisely the same structure, same row count and same field values.
It´s safe to do that if the receiving TClientDataset
does not have any field structure previously defined or the existing structure is compatible with the Data
being assigned. However, if we are talking about a huge number of records, the assignment may take long time and, in an extreme circumstance, it could exaust the computer´s memory (it all the depends on the computer´s configuration).
In order to release the Data, just close the dataset.
If you prefer to have two instances of TClientDataset
but one single instance of the records, my suggestion is to use the TClientDataset.CloneCursor
method, that instead of copying the Data, just assign a reference to it in a different dataset. In this case it´s the very same Data shared between two different datasets.