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