C# 代码优化!导致iis 频繁重启?

fly_Apple10 2012-04-13 10:39:42

/// <summary>
/// 绑定产品目录列表
/// </summary>
/// <param name="cid">公司ID</param>
protected void BindBigProductCataLog(string cid)
{
Catagary ca = new Catagary();
BllGlodMemberProductCatagorySort bllcatagory = new BllGlodMemberProductCatagorySort();
ArrayList al = ca.GetOfferCatalogIDSort(cid);
ArrayList al2 = bllcatagory.GetCatalogList(cid);
if (al != null && al2 != null)
{
if (al.Count == al2.Count)
{
al = al2;
}
}
DataTable dt = ca.GetAllProductCatalogChildSort(cid);
DataTable dt2 = bllcatagory.GetChildCatalogList(cid);
rptCatalogOne.DataSource = al;
rptCatalogOne.DataBind();
foreach (RepeaterItem rpone in rptCatalogOne.Items)
{
int i = rpone.ItemIndex;
int cateGoryoneId;
if (int.TryParse(al[i].ToString(), out cateGoryoneId))
{
DataTable listTwo = null;
if (dt != null)
{
listTwo = ca.GetChildCatalogListByParentIDSort(cateGoryoneId, dt);
}
DataTable listThree = null;
if (dt2 != null)
{
listThree = ca.GetChildCatalogListByParentIDSort(cateGoryoneId, dt2);
}

DataTable list_temp = null;
if (listThree != null && listTwo != null)
{
if (listTwo.Rows.Count == listThree.Rows.Count)
{
list_temp = listThree;
}
else
{
list_temp = listTwo;
}

}
else
{
list_temp = listTwo;
}
Repeater rptCatalogTwo = (Repeater)rpone.FindControl("rptCatalogTwo");
rptCatalogTwo.DataSource = list_temp;
rptCatalogTwo.DataBind();

//释放资源
listTwo.Dispose();
listTwo = null;
listThree.Dispose();
listThree = null;
list_temp.Dispose();
list_temp = null;

}
}
//后面加上了释放资源
dt.Dispose();
dt = null;
dt2.Dispose();
dt2 = null;
}




http://topic.csdn.net/u/20120413/15/25406b4b-4af8-451c-9cea-7fa65d0855de.html?seed=1619594395&r=78235842#r_78235842

以上代码如何优化?
为什么删我的贴,难道??
...全文
108 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧