From ca50d1b55a0d17a29d7658e82665e9b875c1901d Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 25 Apr 2019 18:03:17 +0200 Subject: [PATCH] Memory optimization of SLA export, logging of memory consumption during SLA slicing (just on Windows as of now). --- src/libslic3r/Rasterizer/Rasterizer.hpp | 15 ++++++--------- src/libslic3r/SLAPrint.cpp | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/Rasterizer/Rasterizer.hpp b/src/libslic3r/Rasterizer/Rasterizer.hpp index d4d2277c4..09b166d98 100644 --- a/src/libslic3r/Rasterizer/Rasterizer.hpp +++ b/src/libslic3r/Rasterizer/Rasterizer.hpp @@ -20,29 +20,26 @@ class RawBytes { void operator()(std::uint8_t *rawptr); }; - std::unique_ptr m_buffer = nullptr; - size_t m_size = 0; + std::vector m_buffer; public: RawBytes() = default; - RawBytes(std::uint8_t *rawptr, size_t s): m_buffer(rawptr), m_size(s) {} + RawBytes(std::uint8_t *rawptr, size_t s): m_buffer(rawptr, rawptr + s) { MinzDeleter()(rawptr); } - size_t size() const { return m_size; } - const uint8_t * data() { return m_buffer.get(); } + size_t size() const { return m_buffer.size(); } + const uint8_t * data() { return m_buffer.data(); } // ///////////////////////////////////////////////////////////////////////// // FIXME: the following is needed for MSVC2013 compatibility // ///////////////////////////////////////////////////////////////////////// RawBytes(const RawBytes&) = delete; - RawBytes(RawBytes&& mv): - m_buffer(std::move(mv.m_buffer)), m_size(mv.m_size) {} + RawBytes(RawBytes&& mv) : m_buffer(std::move(mv.m_buffer)) {} RawBytes& operator=(const RawBytes&) = delete; RawBytes& operator=(RawBytes&& mv) { - m_buffer.swap(mv.m_buffer); - m_size = mv.m_size; + m_buffer = std::move(mv.m_buffer); return *this; } diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 284073ca4..2bbcc700a 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1823,7 +1823,7 @@ void SLAPrint::StatusReporter::operator()( SLAPrint &p, double st, const std::string &msg, unsigned flags) { m_st = st; - BOOST_LOG_TRIVIAL(info) << st << "% " << msg; + BOOST_LOG_TRIVIAL(info) << st << "% " << msg << log_memory_info(); p.set_status(int(std::round(st)), msg, flags); }