'Memory spikes Issue due to deep copy in javascript

We have a service which is running smoothly(no memory spikes) but there is some problem in the expected results so we replaced that shallow copy to deep copy. But after replacing it with deep copy we are seeing regular memory spikes. Is it can be the reason of memory spikes?

// Shallow copy of the currentContext
const traceContext = Object.assign({}, currentContext);  // Before
// Deep copy of the currentContext
let traceContext = JSON.parse(JSON.stringify(currentContext)); // Now


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source