In my app I have something like:
static void Main(string[] args)
{
for(int i=0;i<1000;i++){
MyObj mo=new MyObj();
}
}
When i=536
I'm getting: Unhandled Exception: OutOfMemoryException
I have tried to modify to:
for(int i=0;i<1000;i++){
MyObj mo=new MyObj();
mo=null;
}
How to handle this exception properly?
MyObj class looks roughly as follows:
readonly string _url;
readonly string _username;
readonly string _password;
//more properties here
public MyObj(string username , string passowrd , string host )
{
_url = $"https://{host}";
_username = username;
_password = passowrd;
}
//upload file to server
private void Upload(string path){
//some code that upload the file
}
//get json string about htis file
private void Info(string session){
//some code here
}