Skip to content

Unnecessary GC alloc during every new event (resources, business, design and etc.) #51

@am1goo

Description

@am1goo

Every time then I send any event, SDK creates new Hashtable() as a transient object to copy key/values from source dictionary and turn it to JSON string.
It can be fixed by using hashtable pool to reuse small bunch of created hashtables again and again.

private static string DictionaryToJsonString(IDictionary<string, object> dict)
{
    Hashtable table = new Hashtable();
    if (dict != null)
    {
        foreach (KeyValuePair<string, object> pair in dict)
        {
            table.Add(pair.Key, pair.Value);
        }
    }
    return GA_MiniJSON.Serialize(table);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions