Skip to content
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

Add simdjson_free_memory(): int #64

Open
TysonAndre opened this issue Sep 28, 2022 · 1 comment
Open

Add simdjson_free_memory(): int #64

TysonAndre opened this issue Sep 28, 2022 · 1 comment

Comments

@TysonAndre
Copy link
Collaborator

This may be useful if applications parse megabytes of json on startup, but don't use simdjson for large requests later on.

This would free the buffers used by the underlying C simdjson library

@TysonAndre
Copy link
Collaborator Author

TysonAndre commented Sep 28, 2022

simdjson_warn_unused
inline error_code dom_parser_implementation::allocate(size_t capacity, size_t max_depth) noexcept {
  if (this->max_depth() != max_depth) {
    error_code err = set_max_depth(max_depth);
    if (err) { return err; }
  }
  if (_capacity != capacity) {
    error_code err = set_capacity(capacity);
    if (err) { return err; }
  }
  return SUCCESS;
}

Most of the memory can be freed without this as a workaround by calling simdjson_decode('""') as a side effect of how the C library is implemented - it will always change the depth/capacity

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

No branches or pull requests

1 participant