Hi,
I didn't find the CVIDynamicMemoryInfo in the libs as you tell (and I'm in CVI
5.5p1)
so I implement the function you include and it works well.
But with the otions (SHOW_ALLOCATED_MEMORY), is it possible to tune it just to
have the allocated blocks and bytes and not the complete dump of the allocated
memory ?
Thanks for your help,
Fred.
Peter Ilberg a �crit :
> Denis,
>
> You can use the function CVIDynamicMemoryInfo to check your dynamic
> memory usage. This function was added in CVI 5.5 patch 1. If you're
> using CVI 5.5.1 you can use it directly, it's in the utility
> library. Otherwise you'll have to use the helper function appended
> below.
>
> The function prints the number of memory blocks allocated and the
> total amount of allocated memory in CVI's Debug Output Window. It
> takes four arguments: an optional message to help you associate the
> output with a location in your code, optional values which hold the
> number of allocated blocks and memory on output, and an options field
> which allows you to specify if you want additional information to be
> printed about the memory blocks.
>
> Depending on how much memory you have allocated this function can take
> quite a long time to run (a few seconds) though.
>
> Hope this helps,
>
> Peter
>
> /*************************************/
>
> #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;
> }
>