I have a C function that is called thousands of times and I have noticed that it is the only possible place for a memory leak. I have used Valgrind and Totalview's MemoryScape to check for leaks but they say nothing, yet when the application runs on AIX 6.1 there is a gradual leak.
NOTE: I am using a "leak free" SAP RFC SDK for this, and have spoken to the develops and they say the lib I am using is 100% leak free...so it is not that...
The code is roughly like follows, and is called thousands of times each hour....
int writeMessage(message msg){
...
...
header = ItCreate( "HEADER", HEADER_LEN, 0, 0 );
body = ItCreate( "DATA", DATA_LEN, 0, 0 );
...
...
ItDelete(it_header);
ItDelete(it_body);
...
}
Could those string literals like "HEADER" and "DATA" be causing my small leak? Stupid question but I would rather ask to be safe.
What would be the difference if I declared them as CONSTANTS in this specific case?
Thanks for the help, much appreciated
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…