You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ab...@apache.org on 2019/11/18 12:30:08 UTC

[nifi-minifi-cpp] branch master updated: MINIFICPP-1081 - Lower memory usage for long existing ProcessSessions

This is an automated email from the ASF dual-hosted git repository.

aboda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/master by this push:
     new 1f148a0  MINIFICPP-1081 - Lower memory usage for long existing ProcessSessions
1f148a0 is described below

commit 1f148a0ff7a3b45ef8fb75e28b34e2d103c4193f
Author: Daniel Bakai <ba...@apache.org>
AuthorDate: Fri Nov 15 15:10:43 2019 +0100

    MINIFICPP-1081 - Lower memory usage for long existing ProcessSessions
    
    Signed-off-by: Arpad Boda <ar...@gmail.com>
    
    This closes #684
---
 extensions/rocksdb-repos/FlowFileRepository.cpp | 7 ++++++-
 libminifi/src/core/ProcessSession.cpp           | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/extensions/rocksdb-repos/FlowFileRepository.cpp b/extensions/rocksdb-repos/FlowFileRepository.cpp
index 56df86c..a49a028 100644
--- a/extensions/rocksdb-repos/FlowFileRepository.cpp
+++ b/extensions/rocksdb-repos/FlowFileRepository.cpp
@@ -24,6 +24,7 @@
 #include <vector>
 #include <list>
 #include "FlowFileRecord.h"
+#include "utils/ScopeGuard.h"
 
 namespace org {
 namespace apache {
@@ -109,7 +110,10 @@ void FlowFileRepository::run() {
 }
 
 void FlowFileRepository::prune_stored_flowfiles() {
-  rocksdb::DB* stored_database_;
+  rocksdb::DB* stored_database_ = nullptr;
+  utils::ScopeGuard db_guard([&stored_database_]() {
+    delete stored_database_;
+  });
   bool corrupt_checkpoint = false;
   if (nullptr != checkpoint_) {
     rocksdb::Options options;
@@ -119,6 +123,7 @@ void FlowFileRepository::prune_stored_flowfiles() {
     rocksdb::Status status = rocksdb::DB::OpenForReadOnly(options, FLOWFILE_CHECKPOINT_DIRECTORY, &stored_database_);
     if (!status.ok()) {
       stored_database_ = db_;
+      db_guard.disable();
     }
   } else {
     logger_->log_trace("Could not open checkpoint as object doesn't exist. Likely not needed or file system error.");
diff --git a/libminifi/src/core/ProcessSession.cpp b/libminifi/src/core/ProcessSession.cpp
index 6cf388c..535ca78 100644
--- a/libminifi/src/core/ProcessSession.cpp
+++ b/libminifi/src/core/ProcessSession.cpp
@@ -868,6 +868,8 @@ void ProcessSession::commit() {
     _clonedFlowFiles.clear();
     _deletedFlowFiles.clear();
     _originalFlowFiles.clear();
+
+    _transferRelationship.clear();
     // persistent the provenance report
     this->provenance_report_->commit();
     logger_->log_trace("ProcessSession committed for %s", process_context_->getProcessorNode()->getName());