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
{{ message }}
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
I encountered a memory spike when using robin hood unordered node map with certain payloads.
A link to the compiler explorer snippet is as follows Compiler-Explorer-link
(I occasionally get a compiler returned -1 error from compiler explorer . I suspect its because of the number of lines of code. If this happens on your side , you can follow the second link where I removed the robin hood comments at the start of the file to get it working )
Here's a second link in case the first doesn't work Compiler-Explorer-Second-Link
Essentially when I run the following piece of code
intmain()
{
structValue
{
int arr[20];
};
using Container = robin_hood::unordered_map<int , Value>;
robin_hood::unordered_map<int , Container> containers;
unsigned numMapElements = 1'000;
for(unsigned k =0 ; k < 8 ; ++k)
{
printMemory("Memory at the start of iteration " + std::to_string(k));
for(unsigned i =0 ; i < numMapElements ; ++i)
{
Container tmp;
containers[i] = tmp;
for(unsigned j =0 ; j < 50 ; ++j)
{
containers[i].emplace(j , Value());
}
}
printMemory("Memory at the end of iteration " + std::to_string(k));
}
return0 ;
}
I notice that the memory usage is around 11 MB for the first iteration and 170 MB in the next iteration.
This issue disappears when I change the Container type to robin_hood::unordered_flat_map or std::unordered_map.
This behavior is quite unexpected and I suspect there is some memory issue in the robin_hood::unordered_node_map.
Additionally this only happens happens when using the copy assignment operator on container.
If I change the lines in the inner most loop to the following , the issue disappears
Container tmp;
containers[i] = std::move(tmp);
I have used the following functions to print memory usage
Hi
I encountered a memory spike when using robin hood unordered node map with certain payloads.
A link to the compiler explorer snippet is as follows Compiler-Explorer-link
(I occasionally get a compiler returned -1 error from compiler explorer . I suspect its because of the number of lines of code. If this happens on your side , you can follow the second link where I removed the robin hood comments at the start of the file to get it working )
Here's a second link in case the first doesn't work Compiler-Explorer-Second-Link
Essentially when I run the following piece of code
I notice that the memory usage is around 11 MB for the first iteration and 170 MB in the next iteration.
This issue disappears when I change the Container type to robin_hood::unordered_flat_map or std::unordered_map.
This behavior is quite unexpected and I suspect there is some memory issue in the robin_hood::unordered_node_map.
Additionally this only happens happens when using the copy assignment operator on container.
If I change the lines in the inner most loop to the following , the issue disappears
I have used the following functions to print memory usage
Please let me know if you have any idea why this happens.
Thanks
The text was updated successfully, but these errors were encountered: