Skip to content

[DISSCUSSION] the memory tracking approach that better handles shared buffers #6439

Open
@haohuaijin

Description

@haohuaijin

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

See this comment #6363 (comment),
when the Buffer's data is shared between many Buffer, the capacity() method will always return the total buffer memory usage, which causes the issue #6363, we need discussion the better memory track for shared buffers.

pub fn capacity(&self) -> usize {
self.data.capacity()
}

Describe the solution you'd like

The easy way to do this is to return the length and the unused capacity of the Buffer like pr #6438,

    pub fn capacity(&self) -> usize {
        self.length + self.data.capacity() - self.data.len()
    }
          This is changing what these methods report to something else that I'm not sure is correct. Whilst this formulation may benefit your use-case, there are common situations where it will now under report... Perhaps you might file a ticket to discuss a memory tracking approach that better handles shared buffers, as that is the actual issue here. This is not a bug

Originally posted by @tustvold in #6438 (comment)

But as @tustvold said, we need more discussion.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions