* When saving an oar, save assets when immediately received rather than storing them all up in memory

* Hopefully this will remove out of memory problems when saving large oars on machines without much memory
* It may also speed up saving of large oars
This commit is contained in:
Justin Clarke Casey
2009-05-14 20:37:54 +00:00
parent 02bac7fea4
commit 6277156044
6 changed files with 156 additions and 149 deletions

View File

@@ -109,10 +109,14 @@ namespace OpenSim.Framework.Serialization
// Write two consecutive 0 blocks to end the archive
byte[] finalZeroPadding = new byte[1024];
m_bw.Write(finalZeroPadding);
m_bw.Flush();
m_bw.Close();
lock (m_bw)
{
m_bw.Write(finalZeroPadding);
m_bw.Flush();
m_bw.Close();
}
}
public static byte[] ConvertDecimalToPaddedOctalBytes(int d, int padding)
@@ -197,20 +201,23 @@ namespace OpenSim.Framework.Serialization
header[154] = 0;
// Write out header
m_bw.Write(header);
// Write out data
m_bw.Write(data);
if (data.Length % 512 != 0)
lock (m_bw)
{
int paddingRequired = 512 - (data.Length % 512);
//m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired);
byte[] padding = new byte[paddingRequired];
m_bw.Write(padding);
// Write out header
m_bw.Write(header);
// Write out data
m_bw.Write(data);
if (data.Length % 512 != 0)
{
int paddingRequired = 512 - (data.Length % 512);
//m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired);
byte[] padding = new byte[paddingRequired];
m_bw.Write(padding);
}
}
}
}