Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

Unexpected memory growth from "static std::unique_ptr"

Nate945
Beginner
937 Views

I'm seeing unexpectedly growing memory use in an application and have tracked it back to use of a static std::unique_ptr.  This is reproduced on the below minimal reproducing example

#include <memory>
int main(int argc, char** argv) {
  while(1==1) {
    static std::unique_ptr<int> temp;
    temp.reset();
  }
}

I'm using IntelOneAPI-2021.3.0 and the above example is compiled with default icc arguments.  In the example memory use grows quickly and without bound.  It appears each and every time the program runs past the static line roughly 40 bytes of memory are consumed.  I do not see memory growth with this example, or the original larger application, when using other compilers such as g++.

In the short term I will just avoid use of this pattern.  But wanted to report in case there is some underlying bug here.

Thanks!

 

Labels (1)
0 Kudos
1 Solution
ShivaniK_Intel
Moderator
806 Views

Hi,

 

Could you please let us know whether you have any other reproducer code facing issues with icx compiler 2023.0 with memory growth?

 

If not, we suggest you use icx compiler instead of icc compiler because

 

Intel® C++ Compiler Classic (icc) is deprecated and will be removed in a oneAPI release in the second half of 2023. Intel recommends that customers transition now to using the LLVM-based Intel® oneAPI DPC++/C++ Compiler (icx) for continued Windows* and Linux* support, new language support, new language features, and optimizations.

 

Thanks & Regards

Shivani


View solution in original post

0 Kudos
6 Replies
Nate945
Beginner
924 Views

For a bit more information I also see this same behavior using the more recent IntelOneAPI-2023.0.0.

I'm running on a Linux Red Hat 7 system with CPU info "Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz"

0 Kudos
ShivaniK_Intel
Moderator
901 Views

Hi,

 

Thanks for posting in the Intel forums.

 

Could you please let us know if you are facing a similar issue with Intel(R) oneAPI DPC++/C++ Compiler 2023.0.0 (icx compiler)?

 

Could you also please let us know how you are checking unexpectedly growing memory use in an application?

 

Thanks & Regards

Shivani


0 Kudos
Nate945
Beginner
882 Views

Shivani,

Thanks for the reply. 

For the small example I do not see the memory growth when using icx 2023.0.0.  I also don't see any memory growth when using the 2021.3.0 version of icx.  So it looks like whatever is occurring here might be specific to the classic compiler. 

For checking the memory use on the small example I was just monitoring with the unix 'top' command.  For me the small example reaches ~10GB memory use after ~15 seconds and the system kills it at about the ~60 second mark when the memory use reaches ~60GB.   In the original application the same trends were observed, though it took several hours for the memory to grow to the point of crashing the program, mostly just due to hitting the problematic 'static unique_ptr' line less frequently.

-Nate

0 Kudos
ShivaniK_Intel
Moderator
807 Views

Hi,

 

Could you please let us know whether you have any other reproducer code facing issues with icx compiler 2023.0 with memory growth?

 

If not, we suggest you use icx compiler instead of icc compiler because

 

Intel® C++ Compiler Classic (icc) is deprecated and will be removed in a oneAPI release in the second half of 2023. Intel recommends that customers transition now to using the LLVM-based Intel® oneAPI DPC++/C++ Compiler (icx) for continued Windows* and Linux* support, new language support, new language features, and optimizations.

 

Thanks & Regards

Shivani


0 Kudos
Nate945
Beginner
789 Views

No I don't have any evidence of an issue in icx 2023 regarding this.  So that upgrade path makes sense to me.   Thanks!

-Nate

0 Kudos
ShivaniK_Intel
Moderator
765 Views

Hi,


Thanks for accepting our solution. If you need any additional information please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards

Shivani


0 Kudos
Reply