Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Use actual memory size in receive buffer accounting #31164

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
streams: add DataStream::GetMemoryUsage
  • Loading branch information
laanwj committed Nov 4, 2024
commit 047b5e2af1f03549d85926aa02fed0dfa00d449f
6 changes: 6 additions & 0 deletions src/streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://opensource.org/license/mit/.

#include <memusage.h>
#include <span.h>
#include <streams.h>
#include <util/fs_helpers.h>
Expand Down Expand Up @@ -110,3 111,8 @@ bool AutoFile::Truncate(unsigned size)
{
return ::TruncateFile(m_file, size);
}

size_t DataStream::GetMemoryUsage() const noexcept
{
return sizeof(*this) memusage::DynamicUsage(vch);
}
3 changes: 3 additions & 0 deletions src/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 277,9 @@ class DataStream
{
util::Xor(MakeWritableByteSpan(*this), MakeByteSpan(key));
}

/** Compute total memory usage of this object (own memory any dynamic memory). */
size_t GetMemoryUsage() const noexcept;
};

template <typename IStream>
Expand Down