RF Measurement Devices

cancel
Showing results for 
Search instead for 
Did you mean: 

ModtDestroySessionHandle does not free up all memory resource

Solved!
Go to solution

Hi

 

I have a program which attempt to do 1000 iteriations of reading RF message but I get popup error "Not enough memory to complete this operation". look like memory leakage at about 520 iterations.

 

In this loop, I have ModtCreateSessionHandle (&modt_Hdl) at start inside loop and ModtDestroySessionHandle(modt_Hdl); at end inside loop. I had to move both ModtCreateSessionHandle (&modt_Hdl) and and ModtDestroySessionHandle(modt_Hdl) outside the loop to solve the problem.

 

Should and ModtDestroySessionHandle(modt_Hdl) free up all memory resource atttached to mod_Hdl ??

 

Kind regards

Shane

0 Kudos
Message 1 of 2
(5,825 Views)
Solution
Accepted by EI

Hiya Shane,

 

Thanks for your comments. You are quite correct, the ModtDestroySessionHandle should allow you to free internal resources and discards the ModtHandle created using the ModtCreateSessionHandle function. To ensure proper memory deallocation, this function should be called for every ModtHandle created with the ModtCreateSessionHandle function.

 

Therefore, I am surprised to hear about the memory leaks you have discribed. However, regardless of the memory leaks, the process of constantly creating sessions (allocating memory) and destroying sessions (deallocating memory) is horribly ineffecient.

 

The solution you found yourself is a very typical use-case for the modulation functions. By pulling your create and destroy calls outside of the loop, you are only calling them once, but still refferencing the sessions within the loop.

 

I will feed your comments back to our R&D team, to ensure that we are releasing handles and allocated memory space as neatly as possible. However, your original architecture is not an intended usage of the function calls, and the functions may not have been tested this way. My gut feeling is that maybe each time we create the handle, we need a block of contiguous memory. If there is any variation of te handle size, this could cause the "memory leak" over time. My last comment is purely speculative.

 

Ultimately, by following the correct usage of the functions you have improved the programatic effecientcy of yopur application and removed the potencial memory leak.

 

Thanks again for posting your findings.

Best wishes and kind regards,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 2 of 2
(5,794 Views)