I have an angular service having some properties and methods. This is injected in different controllers and all working fine as expected. Now the issue is with the memory conception.
The signature of the class looks like the following:
export class CustomService implements ICustomService {
// Having some variables here
customArray: Array<NameSpace.CustomClass>
constructor() // few injectors here
{
// Some code
}
// Some methods Here
}
One of the property inside the service is an Array of custom object(that is populated using a service call). The number of items in the objects may vary depends on certain parameters sometimes the list may have less than 10 items sometimes it may greater than 100.
Questions:
- Consider that the specific list is now having 100 items, from another controller it is re-assigned with 3 items, will it free the memory for those 97 items(that are previously in that array)?
- Is it possible/needed to free the property inside a service using
delete
- Is there any other reasons for memory leaks when using services