# HG changeset patch # User Sebastien Jodogne # Date 1620200859 -7200 # Node ID 365f51fae4130d1dcc83591df833dd24140be522 # Parent 9804d6490872f3c37489eebe1adb01733455cf3d reduce memory consumption of OrthancPlugins::HttpClient::Execute() in OrthancPluginCppWrapper.h diff -r 9804d6490872 -r 365f51fae413 OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Tue May 04 10:57:42 2021 +0200 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Wed May 05 09:47:39 2021 +0200 @@ -2726,10 +2726,18 @@ delete *it; } + size_ = 0; content_.clear(); } - void Flatten(std::string& target) const + /** + * Since Orthanc 1.9.3, this function also clears the content of + * the ChunkedBuffer in order to mimic the behavior of the + * original class "Orthanc::ChunkedBuffer". This prevents the + * forgetting of calling "Clear()" in order to reduce memory + * consumption. + **/ + void Flatten(std::string& target) { target.resize(size_); @@ -2745,10 +2753,14 @@ memcpy(&target[pos], (*it)->c_str(), s); pos += s; } + + delete *it; } - assert(size_ == 0 || - pos == target.size()); + assert(pos == target.size()); + + size_ = 0; + content_.clear(); } void AddChunk(const void* data, @@ -2779,7 +2791,7 @@ return headers_; } - const ChunkedBuffer& GetBody() const + ChunkedBuffer& GetBody() { return body_; }