-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: expose various low level memory management menthods #3895
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
base: main
Are you sure you want to change the base?
Conversation
SQLite's highwater marks can be 0 when no tracking has occurred yet, even if current values are non-zero. Update test assertions to handle this expected behavior correctly.
sqlx-sqlite/src/connection/mod.rs
Outdated
/// | ||
/// See: https://www.sqlite.org/c3ref/hard_heap_limit64.html | ||
pub fn soft_heap_limit(&mut self, limit: i64) -> i64 { | ||
unsafe { sqlite3_soft_heap_limit64(limit) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The very first line of the linked documentation says:
These interfaces impose limits on the amount of heap memory that will be by all database connections within a single process.
So saying it sets it for the current thread, or having it as a method on the connection. is very misleading.
It should be a free function, or perhaps an associated method of the Sqlite
type. Probably a free function.
Passing a negative number just gets the heap limit and doesn't set it, which also needs to be documented.
A more Rust-y API would be something like limit: Option<NonZeroU64>
, returning an error if it's greater than i64::MAX
(or using a wrapper type with fallible constructors), and providing a separate getter function, but I don't know if we need to go that far. I'd kind of like to sleep on it, though.
sqlx-sqlite/src/connection/mod.rs
Outdated
/// | ||
/// Returns the number of bytes of memory released. | ||
/// | ||
/// See: https://www.sqlite.org/c3ref/release_memory.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This links to the wrong page. It should be: https://www.sqlite.org/c3ref/db_release_memory.html
I'm diagnosing memory usage in an application, I think these would be useful to have.