From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simark@simark.ca>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Free multidicts from blockvector
Date: Fri, 24 Oct 2025 12:04:16 -0600 [thread overview]
Message-ID: <871pmsi3bz.fsf@tromey.com> (raw)
In-Reply-To: <42123ec4-5b99-410d-bde1-3b506117cea6@simark.ca> (Simon Marchi's message of "Fri, 24 Oct 2025 12:25:12 -0400")
Simon> I guess that this restriction of "objects allocated on obstack must be
Simon> trivially destructible" is a bit artificial and arbitrary? It is
Simon> technically fine to allocate on obstack an object having a destructor,
Simon> as long as you ensure the destructor is called at some point. I guess
Simon> the restriction was put because it's easy to forget and error prone.
I think the specific difference from ordinary 'new' is that valgrind
will detect a new-based memory leak, but not an obstack-based leak. So,
in the heap case, the leak will also point out that the destructor isn't
being run; whereas in the obstack case it could go completely unnoticed.
Simon> - There is a ton of blocks created, so it's nice to be able to free
Simon> their memory in O(1). Unfortunately, having to free
Simon> block::m_multidict means that part is O(n), but the less we have to
Simon> do in O(n) the better I guess?
We could also track the ownership of the dictionaries separately,
e.g. with unordered_set<mdict_unique_ptr> or similar. This would reduce
the cost if it matters.
Tom
prev parent reply other threads:[~2025-10-24 18:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 17:17 [PATCH 0/2] Fix memory leak with .debug_types Tom Tromey
2025-10-23 17:17 ` [PATCH 1/2] Two bug fixes in mdict_free Tom Tromey
2025-10-23 18:26 ` Simon Marchi
2025-10-23 18:32 ` Simon Marchi
2025-10-23 18:49 ` Tom Tromey
2025-10-23 17:17 ` [PATCH 2/2] Free multidicts from blockvector Tom Tromey
2025-10-23 18:31 ` Simon Marchi
2025-10-23 18:52 ` Tom Tromey
2025-10-24 14:08 ` Tom Tromey
2025-10-24 16:25 ` Simon Marchi
2025-10-24 18:04 ` Tom Tromey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871pmsi3bz.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox