Hello. 
Protobuf docs says that in c++ impl. strings and bytes are allocated in 
heap even if an arena is used. 
https://protobuf.dev/reference/cpp/arenas/#arenastring 
Is this still relevant?

When i read the protobuf source code, i got a bit confused, because in 
arenastring.h file i found that:
```
// The string pointer is tagged to be either a default, externally owned 
value,
// a mutable heap allocated value, or an arena allocated value. 
```
1. So, if i use arena there would be no heap allocations for string fields. 
Because for std::string allocation memory would be taken from the arena 
instead of the heap. Is this correct?

2. Also, there are Set(const char* s, size_t n, Arena* arena) methods that 
don't use std::string at all. Although, pointer will go to the 
Arena::Create<std::string>(&arena, s.data(), s.length()) method. I didn't 
find what is going on after this, but semantically it shouldn't use heap 
too. Is this correct?

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/2fca20f4-523b-44e7-920a-ec1712576cc5n%40googlegroups.com.

Reply via email to