I have a MVC web application, it is an old and large source, now am modifying it for unit testing purpose. I need to initialize multiple objects in controller's constructor to abstract the DB accessing codes. like below,
public DownloadsController(ICustomerHistory customerHistory = null, ICustomerInfo customerInfo = null, IDownloadInfo downloadInfo = null, IVersionAccess versionAccess = null,
ILeadInformation leadInfo = null, ISalesForce salesForce = null,IEvaluationReleaseBuildModel evaluationReleaseBuildModel=null)
{
_customerHistory = customerHistory ?? new CustomerHistory();
_customerInfo = customerInfo ?? new CustomerInfo();
_downloadInfo = downloadInfo ?? new DownloadInfo();
_versionAccess = versionAccess ?? new VersionAccess();
_leadInformation = leadInfo ?? new LeadInformation();
_salesForce = salesForce ?? new SalesForce();
_evaluationReleaseBuildModel = evaluationReleaseBuildModel ?? new EvaluationReleaseBuildModel();
}
now I am afraid of if any memory problem will occur due to creating multiple objects like this.
- is it create a memory problem?.
- do I need to destroy the object manually or GC will take care of this..?.
- if we manually need to destroy, how to destroy it. I don't know when we need to destroy this object
thanks in advance.