Skip to content
Discussion options

You must be logged in to vote

Think of gcs::Client as a std::shared_ptr<>: copying them is "cheap", also, two copies pointing to the same shared state can be used from two different threads, i.e., this is safe:

void F(gcs::Client a) {
  std::thread t([](gcs::Client b) { /* use b */, a);
  a = ...;
  t.join();
}

but this is not:

void NotSafe(gcs::Client a) {
  std::thread t([](gcs::Client& b) { /* use b */, std::ref(a));
  a = ...; // not safe..
  t.join();
}

With that out of the way:

Even if I don't overwrite the object, our code's memory allocation gear reports memory leak of 192 bytes with above bare bone operations.

Does it say where? It could be a bug that our memory allocation stuff does not detect, or it cou…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@shaileshkm
Comment options

@coryan
Comment options

coryan May 6, 2021
Collaborator

Answer selected by shaileshkm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants