I want to explain the Garbage Collection concept in C#.
Purpose: The definition of Garbage Collection is it will clear the memory space, the type of memory we can call the expired objects that are no longer needed. Advantages
I would like to explain the Generations approach:
Finalizers (~ClassName()): Allow objects to clean up resources before being collected. However, finalizers delay GC, so it's better to use IDisposable for resource management.
protected void Page_Load(object sender, EventArgs e) { this.Page.MaintainScrollPositionOnPostBack = false; if (!IsPostBack) { if (BindArticleInfo()) { hddRawUrl.Value = HiddenRawUrl.Value = Request.RawUrl; hiddenFieldReturnUrl.Value = CommonFunctions.LoginCheckReturnUrl(Request.RawUrl); hddArticleID.Value = ArticleId; MembershipServices membershipServices = new MembershipServices(); DataTable CheckUserMembership = new DataTable(); if (!object.Equals(Session["UserId"], null)) { CheckUserMembership = membershipServices.CheckUserMembership((Session["UserId"].ToString())); } else { non_member.Visible = true; non_member.Attributes.Remove("onclick"); string currentPathAndQuery = Request.Url.PathAndQuery; string encodedUrl = Server.UrlEncode(currentPathAndQuery); non_member.HRef = CommonFunctions.LoginCheckReturnUrl(encodedUrl); } if (CommonFunctions.ValidateDataTable(CheckUserMembership)) { var MembershipExpire = CheckUserMembership.Rows[0]["MembershipExpire"].ToString(); if (DateTime.Parse(MembershipExpire) > DateTime.Now.Date) { download_article.Visible = true; non_member.Visible = false; } else { non_member.Visible = true; download_article.Visible = false; } } else if (Page.User.IsInRole("A") || Page.User.IsInRole("E")) { download_article.Visible = true; non_member.Visible = false; } else { non_member.Visible = true; download_article.Visible = false; } ManageControls(); //string checkStauts = ConfigurationManager.AppSettings["popup"].ToString(); //if (checkStauts != "none") //{ // if (popupBox.Count > 0) // { // Random random = new Random(); // int index = random.Next(popupBox.Count); // switch (popupBox[index].Type) // { // case "Certification": // EbookPopup.InnerHtml = "<div class=\"div-Skill\">\r\n<div class=\"skill-img\">\r\n<img id=\"img\" runat=\"server\" src=" + popupBox[index].ImageURL + ">\r\n</div>\r\n<div class=\"skill-wrap\">\r\n<div class=\"skill-name\">\r\nTest your <span id=\"skillname\" runat=\"server\">" + popupBox[index].Title.ToString() + "</span> skills certifications!\r\n</div>\r\n</div>\r\n</div>\r\n<a href=" + popupBox[index].SiteUrl.ToString() + "?utm_campaign=popup&utm_medium=csharpcorner&utm_source=certification" + " id=\"skillLink\" class=\"btn-success\" runat=\"server\">\r\nGet Started!\r\n</a>"; // break; // case "Ebook": // EbookPopup.InnerHtml = "<div class= \"eBook-wrap\">\r\n <div class=\"e-book-img\">\r\n<a id=\"EbookPopupImageUrl\" runat=\"server\" href=" + popupBox[index].SiteUrl.ToString() + "?utm_campaign=popup&utm_medium=csharpcorner&utm_source=ebook" + " aria-label=\"ebook url\">\r\n<img id=\"EbookPopupImage\" alt=\"CSharp.com Ebook\" runat=\"server\" src=" + HttpUtility.UrlDecode(popupBox[index].ImageURL.ToString()) + "></a>\r\n</div>\r\n<div class=\"e-book-title\">\r\n<p class=\"e-book-title\" id=\"EbookTitles\" runat=\"server\">" + popupBox[index].Title.ToString() + "</p>\r\n<a href=" + popupBox[index].SiteUrl.ToString() + "?utm_campaign=popup&utm_medium=csharpcorner&utm_source=ebook" + " id=\"EbookLink\" runat=\"server\" class=\"btn-primary\">\r\nDownload Now!\r\n</a>\r\n </div>\r\n</div>"; // break; // case "Learn": // EbookPopup.InnerHtml = "<div class=\"div-learn\">\r\n<div class=\"skill-img\">\r\n<img id=\"img1\" runat=\"server\" src=" + popupBox[index].ImageURL + " >\r\n</div>\r\n<div class=\"skill-wrap\">\r\n<div class=\"skill-name\">\r\n" + popupBox[index].Title.ToString() + "\r\n</div>\r\n</div>\r\n</div>\r\n<a href=" + popupBox[index].SiteUrl.ToString() + "?utm_campaign=popup&utm_medium=csharpcorner&utm_source=learn" + " id=\"A1\" class=\"btn-primary\" runat=\"server\">\r\nStart Learning\r\n</a>"; // break; // } // } // else // { // EbookPopup.Visible = false; // } //} //else //{ // popup.Visible = false; //} } else { Response.Redirect(ResolveUrl(ConfigurationManager.AppSettings["PageNotFound"])); } var pageUrl = (ConfigurationManager.AppSettings["SiteUrl"] + Request.RawUrl).ToLower(); CommonFunctions.AddMetaTag("Title", Page.Title, Page, 4); CommonFunctions.AddOgUrlAndTitle(pageUrl, Page.Title, HiddenContentShortDescription.Value.Trim(), Page, "Articles"); } }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: