-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InitAPI memory leak #3168
Comments
I'm not seeing any memory leaks when reproducing this on RHEL9.4. #include <iostream>
#include <aws/core/Aws.h>
using namespace std;
using namespace Aws;
int main() {
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
Aws::InitAPI(options);
{
std::cout << "Test" <<std::endl;
}
Aws::ShutdownAPI(options);
return 0;
} Can you try the following:
Valgrind also put my simple application usage at only 15 MB. So it would be helpful if you could give us a minimal repro code sample that shows a memory leak. |
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one. |
Hi @saad-alsaad1 , thank you for your reply! Best regards, |
Hi @SergeyRyabinin, RAM: 263 GB Centos 8.5: RAM: 32 Centos 7: RAM: 264 GB |
What you're seeing doesn't appear to be a memory leak, but rather the sdk setting up the event loops in proportion to how many threads that you have. To elaborate further the sdk detects that you have 48 CPUs and then will start 24 event loop threads to prepare for processing large amounts of data. You can see the code that decides that number here: /* cut them in half to avoid using hyper threads for the IO work. */
el_count = processor_count > 1 ? processor_count / 2 : processor_count; This can take up a large chunk of memory when you compare it to a instance with only 8CPUs. This would also explain why nothing is showing up on valgraind as there is not memory leak. It would be a problem if you're still seeing large memory usage after the program is terminated. But valgrind would catch if that was the problem. I don't think there are currently any actionable items on this. But please do let us know what expectations/preferences that you have for this sdk. |
Hi @jmklix, |
I would really doubt its related to the number of threads that CRT launched. CRT barely stores any extra meta info for each threads. From my memory, typical ELG memory usage on C5n (which has 72 cores and will run 36 threads by default) is less than 40 MB. do you have a complete sample where you are observing the issue? how are you actually measuring mem usage? |
I get the memory usage from /proc/self/status and parse VmSize value #include <iostream>
#include <aws/core/Aws.h>
using namespace std;
using namespace Aws;
static int parseLine(char* line){
// This assumes that a digit will be found and the line ends in " Kb".
int i = (int)strlen(line);
const char* p = line;
while (*p <'0' || *p > '9') p++;
line[i-3] = '\0';
i = atoi(p);
return i;
}
int getVmMemUsage(void)
{ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];
while (fgets(line, 128, file) != NULL){
if (strncmp(line, "VmSize:", 7) == 0){
result = parseLine(line);
break;
}
}
fclose(file);
return result/1000;
}
int main() {
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
Aws::InitAPI(options);
{
std::cout << "Memory usage in MB: " << getVmMemUsage() << std::endl;
}
Aws::ShutdownAPI(options);
return 0;
} |
Are you sure VmSize is what you are looking for? Looking at proc status docs, it seems like VmSize is the total addressable space of the process and how OS maps that might vary based on hw and other things. |
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one. |
I see totally different numbers between VmRSS and VmSize for the same process and seems VmRSS number make more sense. |
As noted here:
So your 17.04 MB VmRSS size is normal memory size by this sdk. Please let us know if you have any other questions about this sdk |
We had a similar problem when upgrading aws-sdk-cpp from v1.7 to v.1.11 and using a S3Client in an application. Anyway, we could lower the numbers from the additional 150MB to 31MB by tuning the number of initiated threads via Not sure if this can help you @saad-alsaad1 , but see this simple example. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
I've compiled AWS SDK on three RHEL machines. RHEL7, RHEL8, and RHEL9
I noticed that when I call Aws::InitAPI(options) the memory raise by 1847 MB on RHEL7 and RHEL9!
while on RHEL8 Aws::InitAPI(options) API consume around 370 MB.
Also, when I call the Aws::ShutdownAPI(options) function it only free 50 MB.
I've the following library versions on each machine:
RHEL7:
Cmake: 3.14.2
GCC: 8.3.1
libz: 1.2.7
libcurl: 7.29.0
OpenSSL & libcrypto: 1.0.2k
Python: 3.6.8
RHEL8:
Cmake: 3.14.2
GCC: 8.5.0
libz: 1.2.11
libcurl: 7.61.1
OpenSSL & libcrypto: 1.1.1k
Python: 3.6.8
RHEL9:
Cmake: 3.26.5
GCC: 11.4.1
libz: 1.2.11
libcurl: 7.76.1
OpenSSL & libcrypto: 3.0.7
Python: 3.9.18
I used the following command to compile AWS SDK on the machines:
./aws-sdk-cpp -DCMAKE_BUILD_TYPE=Release -DCURL_INCLUDE_DIR=/usr/include/ -DBUILD_ONLY="s3;sts;s3-crt;ec2;core;ec2-instance-connect;ecr;ecs;ecr-public;s3control;transfer;iam;identity-management;access-management;monitoring;s3-encryption" -DCMAKE_PREFIX_PATH=./aws-sdk-libs -DCMAKE_INSTALL_PREFIX=./aws-sdk-libs -DBUILD_SHARED_LIBS=ON
Code:
Regression Issue
Expected Behavior
I believe Aws::InitAPI shouldn't need around 1.8 GB of memory on Centos 7 and 9 since on Centos 8 it only consume 370 MB of memory.
I guess Aws::ShutdownAPI should clean all the memory allocated by Aws::InitAPI.
Current Behavior
Aws::InitAPI(options) take 1847 MB of memory on RHEL7 and RHEL9, but on RHEL8 it only take 370 MB.
Aws::ShutdownAPI(options) doesn't free all the memory allocated by Aws::InitAPI(options).
Reproduction Steps
Compile AWS SDK on RHEL 7.6 or RHEL 9.4 with the follow libs:
RHEL7:
Cmake: 3.14.2
GCC: 8.3.1
libz: 1.2.7
libcurl: 7.29.0
OpenSSL & libcrypto: 1.0.2k
Python: 3.6.8
RHEL9:
Cmake: 3.26.5
GCC: 11.4.1
libz: 1.2.11
libcurl: 7.76.1
OpenSSL & libcrypto: 3.0.7
Python: 3.9.18
Use the following command for compilation:
./aws-sdk-cpp -DCMAKE_BUILD_TYPE=Release -DCURL_INCLUDE_DIR=/usr/include/ -DBUILD_ONLY="s3;sts;s3-crt;ec2;core;ec2-instance-connect;ecr;ecs;ecr-public;s3control;transfer;iam;identity-management;access-management;monitoring;s3-encryption" -DCMAKE_PREFIX_PATH=./aws-sdk-libs -DCMAKE_INSTALL_PREFIX=./aws-sdk-libs -DBUILD_SHARED_LIBS=ON
Possible Solution
No response
Additional Information/Context
No response
AWS CPP SDK version used
1.11.365
Compiler and Version used
gcc 8.3.1 & gcc 8.5.0 & gcc 11.4.1
Operating System and version
Centos 7.6 & Centos 8.5.2 & Centos 9.4
The text was updated successfully, but these errors were encountered: