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

Fix memory leak (24GB per second) when rodeos starts with --filter-wa… #10519

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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