Some more memory tracking
This commit is contained in:
parent
dedb16bc73
commit
0bdf1778cb
|
@ -831,6 +831,8 @@ const CommandDesc debug_cmd = {
|
||||||
write_debug("InternedString: " + to_string(UsedMemory<MemoryDomain::InternedString>::byte_count));
|
write_debug("InternedString: " + to_string(UsedMemory<MemoryDomain::InternedString>::byte_count));
|
||||||
write_debug("BufferContent: " + to_string(UsedMemory<MemoryDomain::BufferContent>::byte_count));
|
write_debug("BufferContent: " + to_string(UsedMemory<MemoryDomain::BufferContent>::byte_count));
|
||||||
write_debug("BufferMeta: " + to_string(UsedMemory<MemoryDomain::BufferMeta>::byte_count));
|
write_debug("BufferMeta: " + to_string(UsedMemory<MemoryDomain::BufferMeta>::byte_count));
|
||||||
|
write_debug("Options: " + to_string(UsedMemory<MemoryDomain::Options>::byte_count));
|
||||||
|
write_debug("Highlight: " + to_string(UsedMemory<MemoryDomain::Highlight>::byte_count));
|
||||||
write_debug("WordDB: " + to_string(UsedMemory<MemoryDomain::WordDB>::byte_count));
|
write_debug("WordDB: " + to_string(UsedMemory<MemoryDomain::WordDB>::byte_count));
|
||||||
write_debug("Undefined: " + to_string(UsedMemory<MemoryDomain::Undefined>::byte_count));
|
write_debug("Undefined: " + to_string(UsedMemory<MemoryDomain::Undefined>::byte_count));
|
||||||
write_debug("Malloced: " + to_string(mallinfo().uordblks));
|
write_debug("Malloced: " + to_string(mallinfo().uordblks));
|
||||||
|
@ -949,11 +951,11 @@ const CommandDesc declare_option_cmd = {
|
||||||
else if (parser[0] == "regex")
|
else if (parser[0] == "regex")
|
||||||
opt = ®.declare_option<Regex>(parser[1], docstring, Regex{}, flags);
|
opt = ®.declare_option<Regex>(parser[1], docstring, Regex{}, flags);
|
||||||
else if (parser[0] == "int-list")
|
else if (parser[0] == "int-list")
|
||||||
opt = ®.declare_option<std::vector<int>>(parser[1], docstring, {}, flags);
|
opt = ®.declare_option<Vector<int, MemoryDomain::Options>>(parser[1], docstring, {}, flags);
|
||||||
else if (parser[0] == "str-list")
|
else if (parser[0] == "str-list")
|
||||||
opt = ®.declare_option<std::vector<String>>(parser[1], docstring, {}, flags);
|
opt = ®.declare_option<Vector<String, MemoryDomain::Options>>(parser[1], docstring, {}, flags);
|
||||||
else if (parser[0] == "line-flag-list")
|
else if (parser[0] == "line-flag-list")
|
||||||
opt = ®.declare_option<std::vector<LineAndFlag>>(parser[1], docstring, {}, flags);
|
opt = ®.declare_option<Vector<LineAndFlag, MemoryDomain::Options>>(parser[1], docstring, {}, flags);
|
||||||
else
|
else
|
||||||
throw runtime_error("unknown type " + parser[0]);
|
throw runtime_error("unknown type " + parser[0]);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const override;
|
Completions complete_child(StringView path, ByteCount cursor_pos, bool group) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using HighlighterMap = IdMap<std::unique_ptr<Highlighter>>;
|
using HighlighterMap = IdMap<std::unique_ptr<Highlighter>, MemoryDomain::Highlight>;
|
||||||
HighlighterMap m_highlighters;
|
HighlighterMap m_highlighters;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ void apply_highlighter(const Context& context,
|
||||||
{
|
{
|
||||||
using LineIterator = DisplayBuffer::LineList::iterator;
|
using LineIterator = DisplayBuffer::LineList::iterator;
|
||||||
LineIterator first_line;
|
LineIterator first_line;
|
||||||
std::vector<DisplayLine::iterator> insert_pos;
|
Vector<DisplayLine::iterator> insert_pos;
|
||||||
auto line_end = display_buffer.lines().end();
|
auto line_end = display_buffer.lines().end();
|
||||||
|
|
||||||
DisplayBuffer region_display;
|
DisplayBuffer region_display;
|
||||||
|
@ -159,7 +159,7 @@ auto apply_face = [](const Face& face)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
using FacesSpec = std::vector<String>;
|
using FacesSpec = Vector<String, MemoryDomain::Highlight>;
|
||||||
|
|
||||||
static HighlighterAndId create_fill_highlighter(HighlighterParameters params)
|
static HighlighterAndId create_fill_highlighter(HighlighterParameters params)
|
||||||
{
|
{
|
||||||
|
@ -271,7 +271,7 @@ private:
|
||||||
{
|
{
|
||||||
std::pair<LineCount, LineCount> m_range;
|
std::pair<LineCount, LineCount> m_range;
|
||||||
size_t m_timestamp = 0;
|
size_t m_timestamp = 0;
|
||||||
std::vector<std::vector<BufferRange>> m_matches;
|
Vector<Vector<BufferRange, MemoryDomain::Highlight>, MemoryDomain::Highlight> m_matches;
|
||||||
};
|
};
|
||||||
BufferSideCache<Cache> m_cache;
|
BufferSideCache<Cache> m_cache;
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ struct RegexMatch
|
||||||
ByteCoord begin_coord() const { return { line, begin }; }
|
ByteCoord begin_coord() const { return { line, begin }; }
|
||||||
ByteCoord end_coord() const { return { line, end }; }
|
ByteCoord end_coord() const { return { line, end }; }
|
||||||
};
|
};
|
||||||
using RegexMatchList = std::vector<RegexMatch>;
|
using RegexMatchList = Vector<RegexMatch, MemoryDomain::Highlight>;
|
||||||
|
|
||||||
void find_matches(const Buffer& buffer, RegexMatchList& matches, const Regex& regex)
|
void find_matches(const Buffer& buffer, RegexMatchList& matches, const Regex& regex)
|
||||||
{
|
{
|
||||||
|
@ -870,7 +870,7 @@ struct RegionDesc
|
||||||
struct RegionsHighlighter : public Highlighter
|
struct RegionsHighlighter : public Highlighter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using NamedRegionDescList = std::vector<std::pair<String, RegionDesc>>;
|
using NamedRegionDescList = Vector<std::pair<String, RegionDesc>, MemoryDomain::Highlight>;
|
||||||
|
|
||||||
RegionsHighlighter(NamedRegionDescList regions, String default_group)
|
RegionsHighlighter(NamedRegionDescList regions, String default_group)
|
||||||
: m_regions{std::move(regions)}, m_default_group{std::move(default_group)}
|
: m_regions{std::move(regions)}, m_default_group{std::move(default_group)}
|
||||||
|
@ -1005,7 +1005,7 @@ public:
|
||||||
private:
|
private:
|
||||||
const NamedRegionDescList m_regions;
|
const NamedRegionDescList m_regions;
|
||||||
const String m_default_group;
|
const String m_default_group;
|
||||||
IdMap<HighlighterGroup> m_groups;
|
IdMap<HighlighterGroup, MemoryDomain::Highlight> m_groups;
|
||||||
|
|
||||||
struct Region
|
struct Region
|
||||||
{
|
{
|
||||||
|
@ -1013,13 +1013,13 @@ private:
|
||||||
ByteCoord end;
|
ByteCoord end;
|
||||||
StringView group;
|
StringView group;
|
||||||
};
|
};
|
||||||
using RegionList = std::vector<Region>;
|
using RegionList = Vector<Region, MemoryDomain::Highlight>;
|
||||||
|
|
||||||
struct Cache
|
struct Cache
|
||||||
{
|
{
|
||||||
size_t timestamp = 0;
|
size_t timestamp = 0;
|
||||||
std::vector<RegionMatches> matches;
|
Vector<RegionMatches, MemoryDomain::Highlight> matches;
|
||||||
UnorderedMap<BufferRange, RegionList> regions;
|
UnorderedMap<BufferRange, RegionList, MemoryDomain::Highlight> regions;
|
||||||
};
|
};
|
||||||
BufferSideCache<Cache> m_cache;
|
BufferSideCache<Cache> m_cache;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
using StringList = std::vector<String>;
|
using StringList = Vector<String, MemoryDomain::Options>;
|
||||||
|
|
||||||
String option_to_string(const InsertCompleterDesc& opt)
|
String option_to_string(const InsertCompleterDesc& opt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,14 +33,14 @@ struct InsertCompleterDesc
|
||||||
Optional<String> param;
|
Optional<String> param;
|
||||||
};
|
};
|
||||||
|
|
||||||
using InsertCompleterDescList = std::vector<InsertCompleterDesc>;
|
using InsertCompleterDescList = Vector<InsertCompleterDesc, MemoryDomain::Options>;
|
||||||
|
|
||||||
|
|
||||||
String option_to_string(const InsertCompleterDesc& opt);
|
String option_to_string(const InsertCompleterDesc& opt);
|
||||||
void option_from_string(StringView str, InsertCompleterDesc& opt);
|
void option_from_string(StringView str, InsertCompleterDesc& opt);
|
||||||
|
|
||||||
using ComplAndDesc = std::pair<String, String>;
|
using ComplAndDesc = std::pair<String, String>;
|
||||||
using ComplAndDescList = std::vector<ComplAndDesc>;
|
using ComplAndDescList = Vector<ComplAndDesc>;
|
||||||
|
|
||||||
struct InsertCompletion
|
struct InsertCompletion
|
||||||
{
|
{
|
||||||
|
|
|
@ -212,7 +212,7 @@ void register_options()
|
||||||
reg.declare_option("path", "path to consider when trying to find a file",
|
reg.declare_option("path", "path to consider when trying to find a file",
|
||||||
std::vector<String>({ "./", "/usr/include" }));
|
std::vector<String>({ "./", "/usr/include" }));
|
||||||
reg.declare_option("completers", "insert mode completers to execute.",
|
reg.declare_option("completers", "insert mode completers to execute.",
|
||||||
std::vector<InsertCompleterDesc>({
|
InsertCompleterDescList({
|
||||||
InsertCompleterDesc{ InsertCompleterDesc::Filename },
|
InsertCompleterDesc{ InsertCompleterDesc::Filename },
|
||||||
InsertCompleterDesc{ InsertCompleterDesc::Word, "all"_str }
|
InsertCompleterDesc{ InsertCompleterDesc::Word, "all"_str }
|
||||||
}), OptionFlags::None);
|
}), OptionFlags::None);
|
||||||
|
|
|
@ -15,6 +15,8 @@ enum class MemoryDomain
|
||||||
InternedString,
|
InternedString,
|
||||||
BufferContent,
|
BufferContent,
|
||||||
BufferMeta,
|
BufferMeta,
|
||||||
|
Options,
|
||||||
|
Highlight,
|
||||||
WordDB
|
WordDB
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "flags.hh"
|
#include "flags.hh"
|
||||||
#include "option_types.hh"
|
#include "option_types.hh"
|
||||||
#include "regex.hh"
|
#include "regex.hh"
|
||||||
|
#include "vector.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
@ -91,7 +92,7 @@ public:
|
||||||
CandidateList complete_option_name(StringView prefix,
|
CandidateList complete_option_name(StringView prefix,
|
||||||
ByteCount cursor_pos);
|
ByteCount cursor_pos);
|
||||||
|
|
||||||
using OptionList = std::vector<const Option*>;
|
using OptionList = Vector<const Option*>;
|
||||||
OptionList flatten_options() const;
|
OptionList flatten_options() const;
|
||||||
|
|
||||||
void register_watcher(OptionManagerWatcher& watcher);
|
void register_watcher(OptionManagerWatcher& watcher);
|
||||||
|
@ -108,10 +109,10 @@ private:
|
||||||
template<typename MatchingFunc>
|
template<typename MatchingFunc>
|
||||||
CandidateList get_matching_names(MatchingFunc func);
|
CandidateList get_matching_names(MatchingFunc func);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Option>> m_options;
|
Vector<std::unique_ptr<Option>, MemoryDomain::Options> m_options;
|
||||||
OptionManager* m_parent;
|
OptionManager* m_parent;
|
||||||
|
|
||||||
std::vector<OptionManagerWatcher*> m_watchers;
|
Vector<OptionManagerWatcher*, MemoryDomain::Options> m_watchers;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -153,6 +154,18 @@ public:
|
||||||
{
|
{
|
||||||
return new TypedOption{manager, m_desc, m_value};
|
return new TypedOption{manager, m_desc, m_value};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using Alloc = Allocator<TypedOption, MemoryDomain::Options>;
|
||||||
|
static void* operator new (std::size_t sz)
|
||||||
|
{
|
||||||
|
kak_assert(sz == sizeof(TypedOption));
|
||||||
|
return Alloc{}.allocate(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void operator delete (void* ptr)
|
||||||
|
{
|
||||||
|
return Alloc{}.deallocate(reinterpret_cast<TypedOption*>(ptr), 1);
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
T m_value;
|
T m_value;
|
||||||
};
|
};
|
||||||
|
@ -216,7 +229,7 @@ public:
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
OptionManager& m_global_manager;
|
OptionManager& m_global_manager;
|
||||||
std::vector<std::unique_ptr<OptionDesc>> m_descs;
|
Vector<std::unique_ptr<OptionDesc>, MemoryDomain::Options> m_descs;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user