When using https url i am facing memory leaks and with http protocol it works fine . I ran profiler here is the result . I tried every thing but no use memory keeps increasing with every request .
 public class HttpService<T> where T : class
    {
        public static T GetResponse(string url, string data, string username = null, string password = null, Int64 ConId = 0, ControllerModel cont = null, string authType = "Digest", bool _isCameraServer = false, [CallerLineNumber] long callerLineNumber = 0, [CallerFilePath] string callerFilePath = "")
        {
           // url = url.ToLower();
           //url = url.Replace("https", "http");
            string pageContent = "";
            try
            {
                Uri myUri = new Uri(url);
                #region For HTTPS
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                       | SecurityProtocolType.Tls11
                       | SecurityProtocolType.Tls12
                       | SecurityProtocolType.Ssl3;
                ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
                #endregion
                if (_isCameraServer)
                {
                    ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
                }
                using (WebClient cli = new WebClient())
                {
                    cli.Headers.Add("Cache-Control", "no-cache");
                    cli.Headers.Add("Cache-Control", "no-store");
                    cli.Headers.Add("User-Agent", "Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36");
                    
                    cli.Headers[HttpRequestHeader.ContentType] = "application/json";                         
                    cli.Credentials = new NetworkCredential(username, password);
                    cli.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);                    
                    string res = cli.UploadString(url,"POST", data);
                var ss = JsonConvert.DeserializeObject<T>(res);
                    res = null;
                return ss;
                }
            }
            catch (StackOverflowException ex)
            {
                Helper.Log(ex);
                return null;
            }
            catch (Exception ex)
            {
                Helper.Log(ex);            
                return null;
            }
        }
    }
