Leaks versus Growth

Leaks versus Growth

I'm having trouble getting Inspector to report memory growth issues. My assumption is that any memory allocated, but not deallocated, between a transaction start and end, would be reported as memory growth.I'm finding that there's a lot of memory that's growing that is not being detected by Inspector XE. I even put in a "canary" to make sure that I'd get some sort of reading. Here's the sample code:static std::vector tmp2;Foo(csref s) {tmp2.push_back("lskdfjlsdkfjlsdkfjlsdkfjlsdkfjsldkfsldksjdf");/// rest of function below....Inspector does not report that as memory growth.Is there something that I'm missing on how memory growth detection works? BTW, I'm running "Locate Memory Problems", and this is 64 bit optimized code.

9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

As I know Inspector XEdoes NOT report memory growth, that reports memory leaks.

Memory Checker in Inspector XE will monitor some memory allocation/deallocation APIs, such malloc/free, new/delete, etc. If memory allocation returned memory start address in stack avariables (pointers), they should be deallocated when exit functions.

If your classes andother classes use standard memory allocation/deallocation, memory leakscan be detected.

Regards, Peter

It does report some items as memory growth when I use transaction mode.What exactly is memory growth then?

You are right.

Since Update 6, the tool supports to report "Memory Growth" problem, it occurs when a block of memory is allocated but not deallocated within a specific time segment during application execution.

Here is my simple example code for testing:

#include

#include 
void transaction()

{

   char *str;

   str = (char*) malloc(16);
}
int main()

{
   while (1) {

     transaction();

     Sleep (1000);

   }
   return 0; /* unreachable */

}

Create an Inspector XE projecton GUI to run"Locate MemoryProblem" with program, click "Start" button, afterawhile click "Set Transaction Start"...run program awhile again...click "Set Transaction End". Finally click "Stop" button to terminate application, to get report below.

What I saw is "Memory Growth" problem given, and problematical source allocation was pointed out. However
Object Size is empty, so we can detect it butcannot find exactsize for this memory growth problem.

I will verify this problem with engineering team, and update this soon.

Regards, Peter

Quoting Peter Wang (Intel)...
"Memory Growth" problem, it occurs when a block of memory is allocated but not deallocated within a specific time segment during application execution.
...

How do you define that value? Howcould I know it in advance?

1. Thereare dynamicalgorithms and it is impossible to predict how much memory will be needed for
processing, when it will be requested and when it will be released.

2. Some applications are pre-allocating huge amounts of memory in advance,then usememory and before
exit deallocate.In that scenario there are no Memory Growth problem and there are no Memory Leaks.

So, the Memory Growth concept looks confusing.

3. Some applications are pre-allocating huge amounts of memory in advance,then usememory and before
exit "drop" itand it iscalled as Enforced Memory Leaks. It makes exit for the applicationfaster.

Best regards,
Sergey

PS: I'll provide latera screenshot of howEnforced Memory Leaks works.

This is a screenshot that demonstrates a correct memory release before an application exit:

Note: It takesmore thentwo minutes forthe test application to release almost 2GB of previously allocated memory.

This is a screenshot that demonstrates a casewhen memory is not released before a testapplication exit:

Note:The test application exits almost instantly

Sergey,
Thanks for illustrating the memory drop concept, it is interesting. The "Memory growth" problem finding is intended to specific applications, mostly for "transactional". User uses it only if he know structure of his application (does it use pre-allocation etc). So if you certain there is some "transaction" that should not gain memory growth after finishing, you can use this functionality.
Finding memory growth is not intended for using during the whole application life period. These problems are found only during specified time period, between user-defined marks. If user doesn't press transaction start and stop buttons, the memory growth is not reported.
Regards,Kirill

Quoting Kirill Rogozhin (Intel)...Finding memory growth is not intended for using during the whole application life period. These problems are found only during specified time period, between user-defined marks. If user doesn't press transaction start and stop buttons, the memory growth is not reported...
Thank you for the explanation.

Best regards,
Sergey

Leave a Comment

Please sign in to add a comment. Not a member? Join today