Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
OOM exception help message
Browse files Browse the repository at this point in the history
  • Loading branch information
dobrou committed Jan 30, 2014
1 parent 799f56a commit d93668e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Src/Src/CodeGen/CsvTableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ private IEnumerable<TRow> GetDataDirect()
return FileUtils.CsvReadRows(FilePath, CsvSeparator, new CsvRowMappingBase<TRow>(PropertiesInfo, RelationsInit));
}

public IEnumerator<TRow> GetEnumerator()
private IEnumerable<TRow> GetData()
{
Logger.Log("CsvTableBase<{0}>.GetEnumerator cache:{1}", typeof(TRow).FullName, DataCacheType.ToString());

IEnumerable<TRow> data;
switch (DataCacheType)
{
Expand All @@ -76,8 +74,25 @@ public IEnumerator<TRow> GetEnumerator()
data = dataCache.Value;
break;
}
return data;
}

return data.GetEnumerator();
public IEnumerator<TRow> GetEnumerator()
{
Logger.Log("CsvTableBase<{0}>.GetEnumerator cache:{1}", typeof(TRow).FullName, DataCacheType.ToString());

try
{
return GetData().GetEnumerator();
}
catch (OutOfMemoryException oex)
{
if (DataCacheType == DataCacheTypeEnum.Disabled)
{
throw;
}
throw new OutOfMemoryException("Prevent OOM exceptions by disabling CSV files cache. Add following setting to the query beginning: CsvLINQPadDriver.CodeGen.CsvTableBase.DataCacheType = CsvLINQPadDriver.CodeGen.CsvTableBase.DataCacheTypeEnum.Disabled;", oex);
}
}

IEnumerator IEnumerable.GetEnumerator()
Expand Down

0 comments on commit d93668e

Please sign in to comment.