Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve memory allocation strategy in lhe blob compression #8279

Merged
merged 1 commit into from Mar 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion SimDataFormats/GeneratorProducts/src/LHEXMLStringProduct.cc
Expand Up @@ -34,6 +34,8 @@ void LHEXMLStringProduct::fillCompressedContent(std::istream &input, unsigned in
constexpr unsigned int bufsize = 4096;
char inbuf[bufsize];

const unsigned int threshsize = 32*1024*1024;

//initialize lzma
uint32_t preset = 9;
lzma_stream strm = LZMA_STREAM_INIT;
Expand Down Expand Up @@ -69,7 +71,12 @@ void LHEXMLStringProduct::fillCompressedContent(std::istream &input, unsigned in
//if output blob is full and compression is still going, allocate more memory
if (strm.avail_out == 0 && ret==LZMA_OK) {
unsigned int oldsize = output.size();
output.resize(2*oldsize);
if (oldsize<threshsize) {
output.resize(2*oldsize);
}
else {
output.resize(oldsize + threshsize);
}
strm.next_out = &output[oldsize];
strm.avail_out = output.size() - oldsize;
}
Expand Down