LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVIDynamicMemoryInfo

How to use CVIDynamicMemoryInfo function?
I didn't found any explanation.
Are there any other not documented functions usefull for debuging CVI
applications?

Regards
Jaroslaw Przywieczerski
0 Kudos
Message 1 of 4
(3,928 Views)
CVI 6.0 will have a function panel explaining the use of
CVIDynamicMemoryInfo. It's also included in the beta in the
utility library.

/* Dynamic Memory Information */
#define DYNAMIC_MEMORY_SHOW_ALLOCATED_MEMORY 0x80000000
#define DYNAMIC_MEMORY_SHOW_ALLOCATED_MEMORY_SUMMARY 0x80000001
/* (this last option was added in CVI 6.0, I think) */

int CVIFUNC CVIDynamicMemoryInfo(const char message[],
unsigned int *allocatedBlocks,
unsigned int *allocatedBytes,
unsigned int options);

CVIDynamicMemoryInfo prints the number of memory blocks
allocated and the total amount of allocated memory in CVI's
Debug Output Window. It also shows the first f
ew bytes of
each memory block. The function takes four arguments:

- message: an optional message to help you associate the
output with a location in your code
- allocatedBlocks: the number of allocated blocks (you may
pass NULL)
- allocatedMemory: the total amount of memory (you may pass
NULL)
- options: one of the constants above, or 0 for no output
in the debug output window

Depending on how much memory you have allocated this
function can take quite a long time to run (a few seconds)
when outputing memory information to the debug output
window.

Peter

-- Peter Ilberg
0 Kudos
Message 2 of 4
(3,928 Views)
Your explantations suggest, that the function CVIDynamicMemoryInfo is
available but not documented in CVI 5.5. My CVI 5.5 doesn't know this
function. Is this a bug of mine or is the function not available
in CVI 5.5.

Greetings
Torsten
Peter Ilberg schrieb:
>
> CVI 6.0 will have a function panel explaining the use of
> CVIDynamicMemoryInfo. It's also included in the beta in the
> utility library.
>
> /* Dynamic Memory Information */
> #define DYNAMIC_MEMORY_SHOW_ALLOCATED_MEMORY 0x80000000
> #define DYNAMIC_MEMORY_SHOW_ALLOCATED_MEMORY_SUMMARY 0x80000001
> /* (this last option was added in CVI 6.0, I think) */
>
> int CVIFUNC CVIDynamicMemoryInfo(const char message[],
> unsigned int *allocatedBlocks,
>
unsigned int *allocatedBytes,
> unsigned int options);
>
> CVIDynamicMemoryInfo prints the number of memory blocks
> allocated and the total amount of allocated memory in CVI's
> Debug Output Window. It also shows the first few bytes of
> each memory block. The function takes four arguments:
>
> - message: an optional message to help you associate the
> output with a location in your code
> - allocatedBlocks: the number of allocated blocks (you may
> pass NULL)
> - allocatedMemory: the total amount of memory (you may pass
> NULL)
> - options: one of the constants above, or 0 for no output
> in the debug output window
>
> Depending on how much memory you have allocated this
> function can take quite a long time to run (a few seconds)
> when outputing memory information to the debug output
> window.
>
> Peter
>
> -- Peter Ilberg
0 Kudos
Message 3 of 4
(3,928 Views)
Torsten Levin writes:
> Your explantations suggest, that the function CVIDynamicMemoryInfo is
> available but not documented in CVI 5.5. My CVI 5.5 doesn't know this
> function. Is this a bug of mine or is the function not available
> in CVI 5.5.
>
> Greetings
> Torsten

We've introduced CVIDynamicMemoryInfo in the first patch to
CVI 5.5, however the function wasn't documented as part of
the Utility Library until CVI 5.5.1.

If you don't have the first patch to CVI 5.5 yet you can get
it through anonymous ftp at:

ftp://ftp.ni.com/support/labwindows/cvi/fixes/5.5

Unfortunately, CVIDynamicMemoryInfo isn't directly
accessible in this patch so you need to use it like this:
(you might want to try this before downloading the patch)

--------------------------------------------------------------------
#include
#include
#include


#define SHOW_ALLOCATED_MEMORY 0x80000000

typedef int (CVIFUNC *TDynMemInfo)(char *message,
unsigned int *numAllocBlocks,
unsigned int *numAllocBytes,
unsigned int options);

int MyGetDynamicMemInfo (char *message,
unsigned int *numBlocks,
unsigned int *numBytes,
unsigned int options)
{
HMODULE dll = GetModuleHandle ("cvirte.dll");
TDynMemInfo dmi = (TDynMemInfo)GetProcAddress (dll, "CVIDynamicMemoryInfo");

if (dmi)
return dmi (message, numBlocks, numBytes, SHOW_ALLOCATED_MEMORY);
/* check debug output window for memory information */
/* note: this function may take a few seconds to execute */
/* if many blocks were allocated. */
else
return -1;
}

int main (int argc, char *argv[])
{
unsigned int numAllocatedBlocks, numAllocatedBytes;
void *memory = malloc (1234);

MyGetDynamicMemInfo ("Some Message",
&numAllocatedBlocks,
&numAllocatedBytes,
SHOW_ALLOCATED_MEMORY);

free (memory);

return 0;
}
--------------------------------------------------------------------

Gru�,

Peter

-- Peter Ilberg
0 Kudos
Message 4 of 4
(3,928 Views)