未验证 提交 36d06e59 编写于 作者: W Wang Xiangyu 提交者: GitHub

#3265 fix memory leak (#3413)

* #3265 fix memory leak
Signed-off-by: NWang Xiangyu <xy.wang@zilliz.com>

* fix clang-format
Signed-off-by: NWang Xiangyu <xy.wang@zilliz.com>

* update
Signed-off-by: NWang Xiangyu <xy.wang@zilliz.com>

* comment some change
Signed-off-by: NWang Xiangyu <xy.wang@zilliz.com>
上级 edd4c403
...@@ -44,27 +44,27 @@ class CircleQueue { ...@@ -44,27 +44,27 @@ class CircleQueue {
CircleQueue(CircleQueue&& q) = delete; CircleQueue(CircleQueue&& q) = delete;
public: public:
const_reference operator[](size_type n) { const_reference operator[](size_type n) const {
return data_[n % capacity_]; return data_[n % capacity_];
} }
size_type size_type
front() { front() const {
return front_.load(MEMORY_ORDER); return front_.load(MEMORY_ORDER);
} }
size_type size_type
rear() { rear() const {
return rear_; return rear_;
} }
size_type size_type
size() { size() const {
return size_; return size_;
} }
size_type size_type
capacity() { capacity() const {
return capacity_; return capacity_;
} }
......
...@@ -186,7 +186,7 @@ ResourceMgr::DumpTaskTables() { ...@@ -186,7 +186,7 @@ ResourceMgr::DumpTaskTables() {
ss << ">>>>>>>>>>>>>>>ResourceMgr::DumpTaskTable<<<<<<<<<<<<<<<" << std::endl; ss << ">>>>>>>>>>>>>>>ResourceMgr::DumpTaskTable<<<<<<<<<<<<<<<" << std::endl;
for (auto& resource : resources_) { for (auto& resource : resources_) {
ss << resource->name() << std::endl; ss << resource->name() << std::endl;
ss << resource->task_table().Dump().dump(); ss << resource->task_table().Dump().dump() << std::endl;
ss << resource->name() << std::endl << std::endl; ss << resource->name() << std::endl << std::endl;
} }
return ss.str(); return ss.str();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "utils/Log.h" #include "utils/Log.h"
#include "utils/TimeRecorder.h" #include "utils/TimeRecorder.h"
#include <src/scheduler/task/SearchTask.h>
#include <ctime> #include <ctime>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
...@@ -170,7 +171,6 @@ TaskTable::PickToLoad(uint64_t limit) { ...@@ -170,7 +171,6 @@ TaskTable::PickToLoad(uint64_t limit) {
} }
if (not cross && table_[index]->IsFinish()) { if (not cross && table_[index]->IsFinish()) {
table_.set_front(index); table_.set_front(index);
table_[index]->SetFinished(FinishedTask::Create());
} else if (table_[index]->state == TaskTableItemState::LOADED) { } else if (table_[index]->state == TaskTableItemState::LOADED) {
cross = true; cross = true;
++loaded_count; ++loaded_count;
...@@ -258,7 +258,6 @@ TaskTable::PickToExecute(uint64_t limit) { ...@@ -258,7 +258,6 @@ TaskTable::PickToExecute(uint64_t limit) {
if (not cross && table_[index]->IsFinish()) { if (not cross && table_[index]->IsFinish()) {
table_.set_front(index); table_.set_front(index);
table_[index]->SetFinished(FinishedTask::Create());
} else if (table_[index]->state == TaskTableItemState::LOADED) { } else if (table_[index]->state == TaskTableItemState::LOADED) {
cross = true; cross = true;
indexes.push_back(index); indexes.push_back(index);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "scheduler/resource/Resource.h" #include "scheduler/resource/Resource.h"
#include "scheduler/SchedInst.h" #include "scheduler/SchedInst.h"
#include "scheduler/Utils.h" #include "scheduler/Utils.h"
#include "scheduler/task/FinishedTask.h"
#include <iostream> #include <iostream>
#include <limits> #include <limits>
...@@ -173,6 +174,7 @@ Resource::loader_function() { ...@@ -173,6 +174,7 @@ Resource::loader_function() {
task_item->Loaded(); task_item->Loaded();
if (task_item->from) { if (task_item->from) {
task_item->from->Moved(); task_item->from->Moved();
// task_item->from->task = FinishedTask::Create();
task_item->from = nullptr; task_item->from = nullptr;
} }
if (subscriber_) { if (subscriber_) {
...@@ -202,6 +204,7 @@ Resource::executor_function() { ...@@ -202,6 +204,7 @@ Resource::executor_function() {
} }
auto start = get_current_timestamp(); auto start = get_current_timestamp();
Process(task_item->task); Process(task_item->task);
// task_item->task = FinishedTask::Create();
auto finish = get_current_timestamp(); auto finish = get_current_timestamp();
++total_task_; ++total_task_;
total_cost_ += finish - start; total_cost_ += finish - start;
......
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
#include "Connection.h" #include "Connection.h"
#include "Node.h" #include "Node.h"
namespace milvus { namespace milvus::scheduler {
namespace scheduler {
// TODO(wxyu): Storage, Route, Executor // TODO(wxyu): Storage, Route, Executor
enum class ResourceType { enum class ResourceType {
...@@ -197,5 +196,4 @@ class Resource : public Node, public std::enable_shared_from_this<Resource> { ...@@ -197,5 +196,4 @@ class Resource : public Node, public std::enable_shared_from_this<Resource> {
using ResourcePtr = std::shared_ptr<Resource>; using ResourcePtr = std::shared_ptr<Resource>;
using ResourceWPtr = std::weak_ptr<Resource>; using ResourceWPtr = std::weak_ptr<Resource>;
} // namespace scheduler } // namespace milvus::scheduler
} // namespace milvus
...@@ -44,6 +44,7 @@ CheckMagic(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path) { ...@@ -44,6 +44,7 @@ CheckMagic(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path) {
bool result = !strcmp(ch, MAGIC); bool result = !strcmp(ch, MAGIC);
fs_ptr->reader_ptr_->Close(); fs_ptr->reader_ptr_->Close();
free(ch);
return result; return result;
} }
...@@ -83,7 +84,7 @@ ReadHeaderValues(const storage::FSHandlerPtr& fs_ptr, const std::string& file_pa ...@@ -83,7 +84,7 @@ ReadHeaderValues(const storage::FSHandlerPtr& fs_ptr, const std::string& file_pa
result.insert(std::make_pair(pair[0], pair[1])); result.insert(std::make_pair(pair[0], pair[1]));
} }
fs_ptr->reader_ptr_->Close(); fs_ptr->reader_ptr_->Close();
free(ch);
return result; return result;
} }
...@@ -109,7 +110,7 @@ CalculateSum(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path, ...@@ -109,7 +110,7 @@ CalculateSum(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path,
fs_ptr->reader_ptr_->Read(ch, size); fs_ptr->reader_ptr_->Read(ch, size);
std::uint8_t result = crc32c::Crc32c(ch, size); std::uint8_t result = crc32c::Crc32c(ch, size);
fs_ptr->reader_ptr_->Close(); fs_ptr->reader_ptr_->Close();
free(ch);
return result; return result;
} }
...@@ -148,6 +149,7 @@ CheckSum(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path) { ...@@ -148,6 +149,7 @@ CheckSum(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path) {
fs_ptr->reader_ptr_->Close(); fs_ptr->reader_ptr_->Close();
auto sum = static_cast<uint8_t>(atoi(record)); auto sum = static_cast<uint8_t>(atoi(record));
free(record);
return sum == result; return sum == result;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册