Skip to content

HGraph memory leak #1634

@shadowao

Description

@shadowao

Describe the bug
leak backtrace

vsag::SafeAllocator::Allocate(unsigned long) at ??:?
vsag::MemoryBlockIO::DirectReadImpl(unsigned long, unsigned long, bool&) const at ??:?
vsag::FlattenDataCell<vsag::FP32Quantizer<(vsag::MetricType)0>, vsag::MemoryBlockIO>::query(float*, vsag::Computer<vsag::FP32Quantizer<(vsag::MetricType)0> >*, unsigned int const*, unsigned int, vsag::QueryContext*) at ??:?
std::shared_ptr<vsag::DistanceHeap> vsag::BasicSearcher::search_impl<(vsag::InnerSearchMode)1>(std::shared_ptr<vsag::GraphInterface> const&, std::shared_ptr<vsag::FlattenInterface> const&, std::shared_ptr<vsag::VisitedList> const&, void const*, vsag::InnerSearchParam const&, std::shared_ptr<vsag::LabelTable> const&, vsag::QueryContext*) const at ??:?
vsag::BasicSearcher::Search(std::shared_ptr<vsag::GraphInterface> const&, std::shared_ptr<vsag::FlattenInterface> const&, std::shared_ptr<vsag::VisitedList> const&, void const*, vsag::InnerSearchParam const&, std::shared_ptr<vsag::LabelTable> const&, vsag::QueryContext*) const [clone .localalias] at xpointer.c:?
std::shared_ptr<vsag::DistanceHeap> vsag::HGraph::search_one_graph<(vsag::InnerSearchMode)1>(void const*, std::shared_ptr<vsag::GraphInterface> const&, std::shared_ptr<vsag::FlattenInterface> const&, vsag::InnerSearchParam&, std::shared_ptr<vsag::VisitedList> const&, vsag::QueryContext*) const at ??:?
vsag::HGraph::graph_add_one(void const*, int, unsigned int) at ??:?
vsag::HGraph::add_one_point(void const*, int, unsigned int) at ??:?
vsag::HGraph::Add(std::shared_ptr<vsag::Dataset> const&) at ??:?
vsag::IndexImpl<vsag::HGraph>::Add(std::shared_ptr<vsag::Dataset> const&) at ??:?

Analysis
Allocation and Deallocation Logic

  1. Allocation Location (memory_block_io.cpp) memory_block_io.cpp
  2. Release position (flatten_datacell.h) flatten_datacell.h Lines 354-391

Between GetCodesById and Release, ComputeDistsBatch4/ComputeDist is called. Once these functions throw an exception, Release will not be executed, and the allocated 1-4 buffers will leak.

To Reproduce
Codes to reproduce the behavior:

// paste codes here

Environment
Please run bash scripts/check_environment.sh and paste the output here:

  • OS: Linux
  • vsag version: v0.18.2
  • compiler version: e.g. GCC9
  • interface: cpp

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions