Reduced memory usage

Add Memory Usage summary to the log file.
GetJustFormat to reduce memory use
Fix code so that children are not disposed while they are being used
Added new method GetJustFormat to reduce memory use
Fix logic so that content is not used after it is disposed
Verify that Content object is not disposed before using Text
Dispose of parts when Content object is disposed
Verify that ContentInfo object is not disposed before using Text
Dispose of parts when ContentInfo object is disposed
Place brackets around DB names to support names containing periods.
Dispose of parts when Item object is disposed
Removed inapproriate Dispose in MakeItem
Dispose of parts when ItemInfo object is disposed
Remove event handler when ItemInfoList object is disposed
Dispose of parts when Transtion object is disposed
Dispose of parts when ZTransition object is disposed
This commit is contained in:
Rich
2012-05-29 18:02:17 +00:00
parent 58cb0f1c77
commit 9f45759050
15 changed files with 140 additions and 32 deletions

View File

@@ -190,7 +190,7 @@ namespace VEPROMS.CSLA.Library
set
{
if (_Section != null)
_Section.MyContent.MyFormat = value == null ? null : value.Get();
_Section.MyContent.MyFormat = value == null ? null : value.GetJustFormat();
}
}
[Category("Format")]

View File

@@ -316,6 +316,10 @@ namespace VEPROMS.CSLA.Library
}
public partial class FormatInfo : IFormatOrFormatInfo
{
public virtual Format GetJustFormat()
{
return _Editable = Format.GetJustFormat(_FormatID);
}
public static bool HasLatestChanges()
{
if (!HasSeqTabFmtTabToken()) return false;

View File

@@ -423,9 +423,9 @@ namespace VEPROMS.CSLA.Library
using(TransitionInfoList trans = TransitionInfoList.GetAffected(this.ItemID))
{
#region B2012-071 fix JCB
Content oldContent = null;
foreach (TransitionInfo tran in trans)
{
Content oldContent = null;
using (Content content = tran.MyContent.Get())
{
if (oldContent != null && content.ContentID != oldContent.ContentID)
@@ -449,21 +449,22 @@ namespace VEPROMS.CSLA.Library
// content.DTS = DateTime.Now;
// content.Save();
//}
if (oldContent != null)
{
if (oldContent.IsDirty)
{
oldContent.DTS = DateTime.Now;
#region B2012-079 fix JCB
oldContent.UserID = Volian.Base.Library.VlnSettings.UserID + " - Renumber";
#endregion B2012-079 fix JCB
oldContent.Save();
}
else // Update ContentInfo objects to reflect the change in the transition
ContentInfo.Refresh(oldContent);
}
}
}
if (oldContent != null)
{
if (oldContent.IsDirty)
{
oldContent.DTS = DateTime.Now;
#region B2012-079 fix JCB
oldContent.UserID = Volian.Base.Library.VlnSettings.UserID + " - Renumber";
#endregion B2012-079 fix JCB
oldContent.Save();
}
else // Update ContentInfo objects to reflect the change in the transition
ContentInfo.Refresh(oldContent);
}
#endregion B2012-071 fix JCB
}
}

View File

@@ -209,12 +209,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (Disposed) throw new Exception("Attempt to access Disposed Object");
CanReadProperty("Text", true);
return _Text;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (Disposed) throw new Exception("Attempt to access Disposed Object");
CanWriteProperty("Text", true);
if (value == null) value = string.Empty;
if (_Text != value)
@@ -883,13 +885,49 @@ namespace VEPROMS.CSLA.Library
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromDictionaries();
if (_MyZContent != null) // 9.79
{
_MyZContent.Dispose();
_MyZContent = null;
}
if (_ContentParts != null) // 8.93
{
foreach (ContentPart cp in _ContentParts)
cp.Dispose();
_ContentParts = null;
}
if (_MyEntry != null) // .465
{
_MyEntry.Dispose();
_MyEntry = null;
}
if (_MyGrid != null)
{
_MyGrid.Dispose();
_MyGrid = null;
}
Disposed = true;
RemoveFromDictionaries();
_Text = null;
//if (_ContentDetails != null)
// _ContentDetails = null;
//if (_ContentItems != null)
//{
// _ContentItems = null;
// //foreach (ContentItem ci in _ContentItems)
// // ci.Dispose();
//}
//if (_ContentRoUsages != null)
//{
// //foreach (ContentRoUsage cr in _ContentRoUsages)
// // cr.Dispose();
// _ContentRoUsages = null;
//}
//if (_ContentTransitions != null)
//{
// foreach (ContentTransition ct in _ContentTransitions)
// ct.Dispose();
// _ContentTransitions = null;
//}
}
private void RemoveFromDictionaries()
{

View File

@@ -136,6 +136,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_Disposed) throw new Exception("Cannot access disposed object");
CanReadProperty("Text", true);
return _Text;
}
@@ -573,6 +574,25 @@ namespace VEPROMS.CSLA.Library
while (listContentInfo.Contains(this)) listContentInfo.Remove(this); // Remove the item from the list
if (listContentInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
if (_Editable != null)
_Editable = null;
if (_ContentItems != null)
_ContentItems = null;
_Text = null;
//if (_ContentParts != null)
// _ContentParts = null;
//if (_ContentRoUsages != null)
// _ContentRoUsages = null;
//if (_ContentTransitions != null)
// _ContentTransitions = null;
//if (_MyEntry != null)
// _MyEntry = null;
//if (_MyGrid != null)
// _MyGrid = null;
//if (_MyImage != null)
// _MyImage = null;
//if (_MyZContent != null)
// _MyZContent = null;
}
public virtual Content Get()
{

View File

@@ -131,7 +131,7 @@ namespace VEPROMS.CSLA.Library
SqlConnection cn = new SqlConnection(tmp);
cn.Open();
// SqlDataAdapter da = new SqlDataAdapter("select name from sysdatabases where name like 'VEP%' order by name", cn);
SqlDataAdapter da = new SqlDataAdapter("select name, case when object_id(name + '..Items') is null then 'Not PROMS' when object_id(name + '..Revisions') is not null then 'Approval' when object_id(name + '..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
SqlDataAdapter da = new SqlDataAdapter("select name, case when object_id('[' + name + ']..Items') is null then 'Not PROMS' when object_id('[' + name + ']..Revisions') is not null then 'Approval' when object_id('[' + name + ']..ContentAudits') is not null then 'Change Manager' else 'Original' end functionality from sysdatabases where name not in ('master','model','msdb','tempdb') order by name", cn);
DataSet ds = new DataSet();
da.Fill(ds);
cn.Close();

View File

@@ -734,12 +734,26 @@ namespace VEPROMS.CSLA.Library
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
RemoveFromDictionaries();
if (_MyContent != null)
{
_MyContent.Dispose();
_MyContent = null;
}
RemoveFromDictionaries();
if (_ItemTransitions_RangeID != null)
_ItemTransitions_RangeID = null;
if (_ItemTransitions_ToID != null)
_ItemTransitions_ToID = null;
//if (_MyPrevious != null)
// _MyPrevious = null;
//if (_NextItems != null)
// _NextItems = null;
//if (_ItemAnnotations != null)
// _ItemAnnotations.Dispose();
//if (_ItemDocVersions != null)
// _ItemDocVersions = null;
//if (_ItemParts != null)
// _ItemParts = null;
}
private void RemoveFromDictionaries()
{
@@ -787,7 +801,7 @@ namespace VEPROMS.CSLA.Library
{
Item tmp2 = tmp;
tmp = tmp2.Save();
tmp2.Dispose();
//tmp2.Dispose();
}
else
{

View File

@@ -450,6 +450,20 @@ namespace VEPROMS.CSLA.Library
while (listItemInfo.Contains(this)) listItemInfo.Remove(this); // Remove the item from the list
if (listItemInfo.Count == 0) // If there are no items left in the list
_CacheByPrimaryKey.Remove(ItemID.ToString()); // remove the list
if (_MyContent != null)
_MyContent = null;
if (_MyPrevious != null)
_MyPrevious = null;
//if (_ActiveFormat != null)
// _ActiveFormat = null;
//if (_ActiveParent != null)
// _ActiveParent = null;
//if (_ActiveSection != null)
// _ActiveSection = null;
//if (_MyDocVersion != null)
// _MyDocVersion = null;
//if (_ParentNoteOrCaution != null)
// _ParentNoteOrCaution = null;
}
public virtual Item Get()
{

View File

@@ -92,6 +92,7 @@ namespace VEPROMS.CSLA.Library
foreach (ItemInfo tmp in this)
{
tmp.Changed -= new ItemInfoEvent(tmp_Changed);
tmp.Deleted -= new ItemInfoEvent(tmp_Deleted);
}
}
#endregion

View File

@@ -594,6 +594,19 @@ namespace VEPROMS.CSLA.Library
_CountDisposed++;
_Disposed = true;
RemoveFromDictionaries();
if (_MyZTransition != null)
{
_MyZTransition.Dispose();
_MyZTransition = null;
}
if (_MyContent != null)
_MyContent = null;
//if (_MyItemRangeID!=null)
// _MyItemRangeID = null;
//if (_MyItemToID != null)
// _MyItemToID = null;
//if (_MyItemRangeID != null)
// _MyItemRangeID = null;
}
private void RemoveFromDictionaries()
{

View File

@@ -310,6 +310,8 @@ namespace VEPROMS.CSLA.Library
_CountDisposed++;
_Disposed = true;
RemoveFromDictionaries();
if (_MyTransition != null)
_MyTransition = null;
}
private void RemoveFromDictionaries()
{