LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

sscanf memory leak?

I'm using the Full LabWindows/CVI 2010 SP1. To get the issue down to its simplest terms, I made a new user interface project from the template and inserted this code right before DisplayPanel was called:

 

    char portString[1000];
    portString[0] = '\0';
    int length;
    unsigned bytes[32];
    int i;
   
    for (i = 0; i < 10; i++)
    {
        length = sscanf (portString,
        "%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x"
        "%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
        &bytes[0],  &bytes[1],  &bytes[2],  &bytes[3],
        &bytes[4],  &bytes[5],  &bytes[6],  &bytes[7],
        &bytes[8],  &bytes[9],  &bytes[10], &bytes[11],
        &bytes[12], &bytes[13], &bytes[14], &bytes[15],
        &bytes[16], &bytes[17], &bytes[18], &bytes[19],
        &bytes[20], &bytes[21], &bytes[22], &bytes[23],
        &bytes[24], &bytes[25], &bytes[26], &bytes[27],
        &bytes[28], &bytes[29], &bytes[30], &bytes[31]);
    }

 

When I run this in Extended debug mode for either Debug or Debug64, upon exiting the program, the Resource Tracking window says there are ten 510-byte memory buffers still allocated, and they all claim sscanf is the line that allocated the memory. The full application that this came from can do this a lot more than ten times. Should I be concerned about this? A memory leak can't be good.

 

Brian

0 Kudos
Message 1 of 6
(4,109 Views)

Hi Brian,

 

Can you double-check for us which version of cvirte.dll you have in your Windows system directory?

 

Thanks,

Luis

0 Kudos
Message 2 of 6
(4,086 Views)

Luis,

 

My machine where I'm running 32-bit code has 10.0.1.419. The other machine where I ran the 64-bit code has the 2012 beta installed and it's 12.0.0.294.

 

Brian

0 Kudos
Message 3 of 6
(4,082 Views)

The fact that this happens with the 2012 beta is a known issue, but it's not expected to happen with the 2010 SP1 version. Are you sure you're seeing this leak in the machine where you're running your 32-bit code?

 

Luis

0 Kudos
Message 4 of 6
(4,076 Views)

No, I tried the experiments again. I was fooled because 2010 SP1 is also installed on the 64-bit computer with the 2012 beta, and it didn't occur to me that even when I ran it through the 2010 SP1 debugger it was using the 2012 beta runtime library.

 

Now the results make more sense. There's no connection with whether it's a command-line or user-interface application. On the 32-bit machine with only 2010 SP1 installed the issue never happens, and on the 64-bit machine with the 2012 beta installed the issue always happens.

 

Brian

0 Kudos
Message 5 of 6
(4,071 Views)

Yes, that does make sense now. Thanks for the clarification!

 

Luis

0 Kudos
Message 6 of 6
(4,054 Views)