P
PeWi_T-AT
Guest
Dear development community,
In an unmanaged C++ application we have a problem of increasing memory allocation times when executing a set of tasks within multiple threads. Each thread allocates large (1-5 GB) nested std:vector objects which was found to be the bottleneck, as the allocation takes longer every time we allocate a new object, even if previous allocations are freed.
Our found solution was to allocate the memory objects beforehand for each thread and re-using them (clearing) for each run, which helped to reduce the observed effect.
My questions:
A) Is there anyone who's made similar experiences and is the followed approach of pre-allocation a standard solution to such problems?
B) Is there another good way to approach problems like this (e.g. using special OS calls to avoid memory fragmentation / a special library to use)?
If you're experienced in memory problems using C++ / Windows and have some valuable insights to share we'd appreciate.
Thanks,
Regards,
Peter
Continue reading...
In an unmanaged C++ application we have a problem of increasing memory allocation times when executing a set of tasks within multiple threads. Each thread allocates large (1-5 GB) nested std:vector objects which was found to be the bottleneck, as the allocation takes longer every time we allocate a new object, even if previous allocations are freed.
Our found solution was to allocate the memory objects beforehand for each thread and re-using them (clearing) for each run, which helped to reduce the observed effect.
My questions:
A) Is there anyone who's made similar experiences and is the followed approach of pre-allocation a standard solution to such problems?
B) Is there another good way to approach problems like this (e.g. using special OS calls to avoid memory fragmentation / a special library to use)?
If you're experienced in memory problems using C++ / Windows and have some valuable insights to share we'd appreciate.
Thanks,
Regards,
Peter
Continue reading...