Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10519 from EOSIO/fix_filter_memory_leak
Browse files Browse the repository at this point in the history
Fix memory leak (24GB per second) when rodeos starts with --filter-wa…
  • Loading branch information
linhuang-blockone authored Jul 15, 2021
2 parents e8fca32 + 403ac27 commit 3c822b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/rodeos/include/b1/rodeos/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct filter_state : b1::rodeos::data_state<backend_t>, b1::rodeos::console_sta
#ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED
std::optional<eosvmoc_tier> eosvmoc_tierup;
#endif

~filter_state();
};

struct callbacks : b1::rodeos::chaindb_callbacks<callbacks>,
Expand Down
2 changes: 2 additions & 0 deletions libraries/rodeos/include/b1/rodeos/wasm_ql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct shared_state {
struct thread_state : action_state, console_state, query_state {
std::shared_ptr<const shared_state> shared = {};
eosio::vm::wasm_allocator wa = {};

~thread_state();
};

class thread_state_cache : public std::enable_shared_from_this<thread_state_cache> {
Expand Down
5 changes: 5 additions & 0 deletions libraries/rodeos/rodeos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ void rodeos_db_snapshot::write_deltas(const ship_protocol::get_blocks_result_v2&
write_deltas(block_num, result.deltas, shutdown);
}

filter::filter_state::~filter_state() {
// wasm allocator must be explicitly freed
wa.free();
}

std::once_flag registered_filter_callbacks;

rodeos_filter::rodeos_filter(eosio::name name, const std::string& wasm_filename, bool profile
Expand Down
5 changes: 5 additions & 0 deletions libraries/rodeos/wasm_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ shared_state::shared_state(std::shared_ptr<chain_kv::database> db)

shared_state::~shared_state() {}

thread_state::~thread_state() {
// wasm allocator must be explicitly freed
wa.free();
}

std::optional<std::vector<uint8_t>> read_code(wasm_ql::thread_state& thread_state, eosio::name account) {
std::optional<std::vector<uint8_t>> code;
if (!thread_state.shared->contract_dir.empty()) {
Expand Down

0 comments on commit 3c822b9

Please sign in to comment.