You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct AllocationStruct
{
string stringField;
string defaultStringField = "Structure Default String Field Must Be Longer Than 32 Bytes";
};
Then, the generated data constructor will allocate memory for the default string value:
AllocationStruct::AllocationStruct(const AllocatorType& allocator) noexcept :
stringField(allocator),
defaultStringField(::std::string_view{"Structure Default String Field Must Be Longer Than 32 Bytes"}, allocator)
{}
If such constructed data are used as an input for reading (zserio::read), then the defaultStringField is reallocated and initialized with the new read value. This introduces undesired heap memory fragmantation during reading.
This problem can be probably solved by a new constructor which won't fill default values. However, such constructor can be misused.
In all cases, heap memory fragmantation can be considered as a problem, so we should pay attention to it.
The text was updated successfully, but these errors were encountered:
Consider the following schema:
Then, the generated data constructor will allocate memory for the default string value:
If such constructed data are used as an input for reading (
zserio::read
), then thedefaultStringField
is reallocated and initialized with the new read value. This introduces undesired heap memory fragmantation during reading.This problem can be probably solved by a new constructor which won't fill default values. However, such constructor can be misused.
In all cases, heap memory fragmantation can be considered as a problem, so we should pay attention to it.
The text was updated successfully, but these errors were encountered: