Skip to content

Expose Regex memory usage info (fixes #943) - #1377

Open
ashdnazg wants to merge 3 commits into
rust-lang:masterfrom
ashdnazg:regex_memory_usage_fn
Open

Expose Regex memory usage info (fixes #943)#1377
ashdnazg wants to merge 3 commits into
rust-lang:masterfrom
ashdnazg:regex_memory_usage_fn

Conversation

@ashdnazg

Copy link
Copy Markdown

Based on #1180

Comment thread src/regex/bytes.rs Outdated
Comment thread src/regex/string.rs Outdated
@BurntSushi

Copy link
Copy Markdown
Member

So actually, thinking through this more, I think this routine is probably totally bunk. In particular, it does not account for the heap memory used by the lazy DFA, which is probably the biggest (ab)user of heap in most regexes.

It's non-trivial to get that heap usage because it's guarded behind a Pool, which specifically does not expose any way of telling how big it is. And doing so is not straight-forward since it's guarded by mutexes.

Unfortunately I think that if you really really need to know about the sizes of regex values, then you'd have to drop down to regex-automata and dead with Cache values directly.

Unfortunately, I just cannot think of a way to write documentation for this routine, as-is, that isn't some kind of outright lie in a meaningful sense.

@ashdnazg

Copy link
Copy Markdown
Author

That makes sense, but it kinda means meta::Regex::memory_usage() is bunk as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants