LabView VB6 Dll interface causes memory leak

Hello

We use a large written in vb6 in our laboratory measurement built house software. Recently, we have added a new detector that is read using a labview vi that is called using a dll directly from vb6. Here, we call the function for example of read_detector which starts the collection of data and in a next step writes the data to a string. When you have finished the called function returns a pointer to the string and its length. VB6, we read this pointer and process data.

This is a memory leak. This could be the case because we presets not memory for labview to write in and so just writing lab data in memory without releasing again? In the current configuration, the function of the dll is just called again and again and each lab view creates a variable outputstring.

If we allocate the memory. How can we achieve for vb6?

Best,

Julian

Well first of all, a handful of string LabVIEW is a very specific type of data LabVIEW. Not only is only LabVIEW himself knows exactly how to allocate and deallocate, but you must also allocate and deallocate in exactly the same instance of LabVIEW. Given that your LabVIEW DLL is executed for this purpose inside the DLL to run LabVIEW, you must also recover the LabVIEW memory manager functions according to DSDisposeHandle() of the lvrt.dll and call it after you are finished with the strings returned by the DLL function. This is however made very complicated since there are circumstances where not lvrt.dll is actually used by your DLL but another LabVIEW runtime system. And if you happen to have two DLLs created with different versions of LabVIEW LabVIEW, each of them will load and use its enforcement LabVIEW system according to DLL load next. Believe me, you don't want to know how next dll works and how to make this opportunity to work in an application. This is the way for Microsoft to create a monster to manage the hell of the DLL and in this way, rather to create exponential version of hell.

You create just two memory leaks for each call of DLL function at the moment. LabVIEW creates a new handle of string for each of the parameters string at each call, you dereference the pointer, and then copy the contents into a SysString. But you let the chain handles LabVIEW blow created around the stack and the next your function call, you initialize the new variables of the battery which is initialized to null and LabVIEW creates two new handles. Also you need to do is to define an "Integer DSDisposeHandle(LStrHandle As Long)" exported lvrt.dll function and call it once you have copied the data of the handle in your SysString for both of these handles.

But basically calling a DLL LabVIEW from no LabVIEW code and using LabVIEW handles string or array as parameters is several times more trouble that it's worth. The easiest would be fair, allocate a large enough buffer beforehand and pass those to the Configuration of the service DLL LabVIEW function to not accept a handful of string LabVIEW but a pointer to a string C instead. Do you work around the problem on the memory allocated by someone else to worry about your own program of VB and duty he properly release. The disadvantage of this approach is, that you should make sure that the memory allocated buffer is large enough for the maximum possible length that your DLL function may never return.

But another approach might be to leave out LabVIEW total here and call the DAQmx APIs directly from VB.

Tags: NI Software

Similar Questions

  • Windows Media Player ActiveX control causes memory leak

    I'm writing an application that will load and play *.avi files in an ActiveX control. The user must be able to load multiple files consecutively in the single player mode. However, it seems to be the memory leak every time that a file is loaded, even if it's the same file. For example, even when you load a small file in *.avi 81KO repeatedly, there is a memory leak ~ 6Mo coherent (as observed in the Manager of tasks). The leak memory is greater when I load larger files.

    I tried to deny it by adding using a Method Close by using the node invoke. It gets about 3 MB of RAM, but when I load the file again, it leaks ~ 9MB, leaving a net leak of ~ 6Mo once again.

    I also used reference close vi (s) to clear the memory ActiveX object, but that did not help either. In other versions of VI, I tried to eliminate the creation of a new IWMPlayer4 object using a shift register, but once again the leak memory persevered...

    It's a simple version of the VI, as well as the small video file attached. In my application, I want to be able to load large video files (~ 600 MB) several times without memory leaks. Thank you in advance for your help!

    -gpho

    Hi jareds.

    Thanks again for test it for me. I use Windows 7 and WMP version 12.

    As you requested, I tested it on a computer with Windows XP and WMP version 9 (and LabVIEW 8.2.1) and the problem of memory has disappeared. I then installed WMP version 11 on the same computer: still no memory problem.

    On the Windows 7 computer, I went back to version 11 using the instructions found on this link, and the problem of memory has disappeared. It seems that memory leak is due to a problem with WMP version 12 (although degraded version 11 on windows 7 has some bugs - and you can't go back to v12).

    Thanks again for the help!

    -gpho

  • GetCurrent() ADFContext causes memory leak

    Hello

    I use jdev 12.1.3.

    I created a project that uses the Services Rest and when I run it in the integrated weblogic I get this

    <oracle.adf.common> <ADFContext> <getCurrent> <Automatically initializing a DefaultContext for getCurrent.
    Caller should ensure that a DefaultContext is proper for this use.
    Memory leaks and/or unexpected behaviour may occur if the automatic initialization is performed improperly.
    This message may be avoided by performing initADFContext before using getCurrent().
    For more information please enable logging for oracle.adf.share.ADFContext at FINEST level.>
    
    
    

    I also have another weblogic, external, to make my application deployments final in which I am also having the same message. The problem is that external stops my services because of this memory leak.

    I looked in my code, and the only reference I had of getCurrent is now deleted.

    I already own classes, make, and rebuild the two projects and I still get the same message.

    In this way, I think that the problem should lie in the services project, but I have no idea where specifically.

    Any help or advice on this subject?

    I looked at if there was a reference to the same problem and I found that unanswered explains my question.

    https://community.Oracle.com/thread/2533050

    Any help is appreciated

    The message tell you that it might be a memory leak, not part.

    In any case, you will need to dig deeper in this issue e.g. seting the log level to the most beautiful (as the message tell you to do). This way you find hence the getCurrent() is called.

    The framework calls this method too on several occasions. If the battery of the adf is not setup properly, you can get these messages. But without a full analysis, you can't fix it.

    If you have a support contract you can ask support.oracle.com for help on this too.

    Timo

  • SetCtrlVal used during the Thread function works causes memory leaks

    I am writing a program that works if... Or not work if... - see the next lines... :-)...

    The program includes a section, mostly GUI - and User Interaction.

    The other part is a DLL. In the DLL we readings on an external consultant controller RS232. Sometimes the controller card needs (called how much) time and this time must pass then the result can be read card controller... and so on...

    Blocking is not GUI-user-program for the expectation of the return value of the DLL functions (which need a few seconds to be finished) I start a thread in the DLL with

    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, THREAD_FunctionX, & tmpTFP, NULL);

    with "tmpTFP" as an instance of type "TYPE_THREAD_FUNCTION_PARAMETERS":

    typedef struct
    {
    //
    int IntVal1;                // 1. Integer-Wert
    int IntVal2;                // 2. Integer-Wert
    int IntVal3;                // 3. Integer-Wert
    int IntVal4;                // 4. Integer-Wert
    int IntVal5;                // 5. Integer-Wert
    //
    int IntBuffer1 [32];            // 1. Integer-buffer (aktuell genugt einer)
    //
    Double DblVal1;                // 1. Double-value
    Double DblVal2;                // 2. Double-value
    Double DblVal3;                // 3. Double-value
    Double DblVal4;                // 4. Double-value
    Double DblVal5;                // 5. Double-value
    //
    char CharVal1;                // 1. (Single)- Tank-Wert
    char CharVal2;                // 2. (Single)- Tank-Wert
    char CharVal3;                // 3. (Single)- Tank-Wert
    char CharVal4;                // 4. (Single)- Tank-Wert
    char CharVal5;                // 5. (Single)- Tank-Wert
    //
    char CharBuffer1 [1024];        // 1. Char buffer (akutell einer genugt)
    //
    } TYPE_THREAD_FUNCTION_PARAMETERS;

    In the GUI-user program - I get fast by default-return value of the thread start function.

    Then I asked the DLL (some global state variables are used for this) when it is finished.

    According to the map-controller (RS232) contacted the waiting time depends on the 'mood' of the controller card.

    In the DLL-mark of the GUI-user-program routine now everything works fine - without using "SetCtrlVal!"

    In my GUI, there is a text box of the info/comment for messages. If I do a few outputs user using 'SetCtrlVal' I always errors, caused by the false "TYPE_THREAD_FUNCTION_PARAMETERS"-values in the service of thread. "» If I set a breakpoint at the beginning thread-function I see mostly erroneous values in my transfer structure variables. If I put a breakpoint in the thread-function-calling 'CmtScheduleThreadPoolFunction (...)"and at the beginning of the thread values are (mostly) correct!

    I tried several and different things - but:

    If I ONLY (!)  Commenting on the (!) of a line with "SetCtrlVal", the program works, all States are asked out of the DLL.

    If I replace the "SetCtrlVal" with a written record-file function clean everything works fine and after completing the program I can look at the log file and see all the user information. BUT with 'SetCtrlVal' instead or set or (...) it does not work.

    My description is maybe not entirely clear, but believe me: only ONE line the «SetCtrlVal "line - should be commented out to let the program run properly!»

    Because if the line "SetCtrlVal"is program-user-GUI, after the call to the thread in the DLL, the DLL-memory seems to be corrupted by the call "SetCtrlVal" in the user-GUI program.»

    Best regards

    F.

    There may be a problem in your structure that your variable is set.

    You said that, after the address of the variable in the thread function the appellant one ends. Now, as you can read help each value passed in parameter threadFunctionData of the layed function must point to an area of memory that persist when the fuction is running: If your variable is defined at the level of the functions it is not valid when the thread runs since the appellant finished and released its local memory.

    Your approach with a global variable is a valid alternative, but if it is the solution, you will find data passed to the thread function must be valid for all his life.

  • call of LabView VB6 DLLs

    Hello

    I have a dll written in VB6 to control some 3rd party hardware

    I already tried to use the node of the library function call but it doesn't seem to work, after that also, I tried to use

    RefNum Automation, entry and select ActiveX class and and locate my DLL but when I select the dll, the following message shows on the screen: the selected file is not a .NET, type library or executable automation assembly.

    Keep on the issue, I tried to save the Visual Basic DLL on the system through the REGSVR32 command but I got another different message (fbidio.dll was loaded, but the DIRegisterServer entry point was not found. This file can not be registered). Looks like the dll that I intend to use is very old.

    Can someone guide me on this issue, what other things I can try.

    Thank you.

    Concerning

    Hello

    The LabView collapse when I try to use the node library call, in my understanding, based on some comments I've seen, it is not possible to use the call library node for the VB dll.

    Anyway I already understood how to control my gear, I found a module update for Active X controls in the web for my hardware and now my application works perfectly with an ActiveX container, then insert the ActiveX object.

    Tounsiiaa so.

    Concerning

  • Manager replace causing memory leaks?

    Hey people!

    Recently, I discovered that the use

    Hello

    I don't think that memory is there, trailing

    It's just number.

    I have debug your application and using the static memory to check.

    allocated and it freeed correctly.

    I'm on a simulator.

  • Loading external Images causes memory leak

    I worked on an Actionscript 2.0 project that essentially loads external images.
    Whenever I have load and unload a new image, memory increases to 1 or 2 MB
    If all the images are in the cache, then it grew 4 or 8 KBs
    In the unloading of the images, I took the charger and the container of the image.
    Any thoughts why it behaves like this?
    Please find the below sample code snippet.


    ////////////
    btn_load.onRelease = function()
    {
    loadImage();
    }
    btn_unLoad.onRelease = function()
    {
    unLoadImage();
    }
    var mcListener:Object = new Object();
    var container1:MovieClip;
    var mcLoader:MovieClipLoader;
    var loader_reference =;
    var n = 0;
    function loadImage() {}
    var image_arr = ["http://xyz.com/image1.png ',' http://xyz.com/image2.png ',' http://xyz.com/image3.png ',' http: /xyz.com/image4.png http://xyz.com/image5.png ',''"];
    image_url var = image_arr [n];
    {if(n==image_arr.) (Length-1)}
    n = 0;
    } else {}
    n ++ ;
    }

    container1 = loader_reference.createEmptyMovieClip ("Container1", loader_reference.getNextHighestDepth ());
    mcLoader = new MovieClipLoader();
    mcLoader.removeListener (mcListener);
    mcLoader.addListener (mcListener);
    mcListener.onLoadComplete = {function(target_mc:MovieClip,_httpStatus:Number):Void}
    }
    mcListener.onLoadInit = {function(target_mc:MovieClip):Void}
    target_mc._x = 300;
    target_mc._y = 200;
    target_mc._width = 300;
    target_mc._height = 250;
    }
    mcLoader.loadClip (image_url container1);
    }
    function unLoadImage() {}
    mcLoader.unloadClip (container1);
    mcLoader = null;
    container1 = null;
    removeMovieClip (loader_reference.container1);
    }
    ////////////

    Thanks in advance.

    This code should run only once.  fix this.

  • Memory leak with RS-485 visa

    I tried to find a slow memory leak in a large application Labview (2012f3). Using perfmon, probes and breakpoints, I could trace the source of the leak of a series VI communication employing a number of nodes VISA. I have attached a slightly simplified version of the VI leaking (serialCommand.vi), as well as a VISA vi initialization and a VI of container to test.

    Did anyone see any problems with the serialCommand VI that could possibly cause memory leak?

    After reading all posts of the forum that I could find on memory leaks and VISA error, I was still unable to stop the leak. SomeofthethingsI'vetriedsofar:

    -J' read VISA Close can cause leaks memory, so I disabled inside the loop (even if he was closing an event, not the port)

    -J' wrote extra carriage at the beginning of the VI returns, before rinsing the pads

    -J' was initially using VISA 5.2; After the upgrade to VISA 5.3, the leak occurred still

    -J' replaced VISA nodes with constant value placeholders, and the leak repaired (not a solution, but the confirmation that it is the location of the leak)

    It may also be worth noting that I don't remember when this leak memory in the previous development when I was watching for leaks, but a few days ago Labview executable generates started fails with the error 1, and the only way to get Labview to successfully build again should fix labview from Add/Remove Programs (Win 7 Ultimate) , so it could be related to a change of version in one of the packages that has been reinstalled.

    Thank you.

    Is there a reason that you use VISA events?  It seems that you expect just a character.  Why not to use playback VISA wait for a byte and use the timeout if the byte is not?

  • Shared Variable memory leak

    Hi all

    I have an urgent matter with sporadic memory leaks in shared variables.

    Occasionally, reading and writing to the variables shared a memory leak. The rate can be increased by turning on "Flush static Variables' disabled in the code,

    I was not able to reproduce with variables shared on the localhost variables however shared running on a target RT PXI seem to cause this problem.

    It is as if something breaks sometimes and causing memory leaks. Perhaps a matter of concurrency of thread/pointer?

    Steps to reproduce:

    1. Start the MemoryLeak.vi and sometimes it does, other times it does not leak memory slowly.
    2. Select the "Flush the shared Variable" vi behind disable schema structure
    3. Watch the memory usage go amok after the restart of the MemoryLeak.vi
    4. Disable the "Flush shared Variable' behind the structure diagram disable
    5. Restart the MemoryLeak.vi and memory leak continues at different speeds depending on how it breaks.
    6. Will cause a memory leak whenever I run the vi, reboot only LV will put it in somewhat nonleaking condition.

    System information:

    • Latest & most f0 LV2012 32-bit SP1 on client and target systems fully implemented at level
    • Client computer Lenovo Thinkpad W530 Win7 Professional 64-bit
    • SMU-8135 controller on an SMU-1078 performer LVRT 12.0.1 cassis

    Help here to an AE or R & D would be nice that I can't solve this problem on my own.

    See photos attached.

    BR,

    / Roger

    CAR #403386 was created to follow up on this matter.

  • Since the upgrade to Sierra MediaLibraryService is causing a memory leak

    Hello.

    I upgraded to Sierra, since as soon as Itunes is launched, the com.apple.medialibraryservice is originally a large memory leak, it keeps in ram more until she takes all (16 GB) and significantly slows down the computer.

    I tried to reset the nvram and smc memory, doesn't change anything.

    Does anyone have an idea on what is causing this leak and is there a solution?

    Yes, I noticed this also. After that I opened iTunes, it's just a matter of time before all the memory gets used up and all departure is wobbly. In particular, bluetooth really gets bug after a certain time, and as soon as I quit iTunes, that's fine.

  • On firefox memory leaks cause blue screens?

    On firefox memory leaks cause blue screens?

    If you encounter blue screen crashes, this majority refers often to an incompatibility with a device driver, especially the graphics drivers. Go to Firefox Safe Mode and disable the use of Firefox hardware acceleration of graphics.

    Assuming that Firefox is closed:

    Hold down the SHIFT key when you start Firefox. You should get a small dialog box. Click on 'Start mode safe' (not reset).

    (If Firefox is running, use Help > restart with disabled modules to call the dialog box.)

    In Firefox, open the Options of the Advanced tab dialog box:

    the button Firefox orange (or the Tools menu) > Options > advanced

    In the mini ' General' tab, uncheck the box for "use hardware acceleration when available.

    This will take effect after you exit Firefox and start it up again (in normal mode).

  • This will cause a memory leak?

    Hello

    I have a question about how AS3 garbage collection.  This will cause a memory leak?

    var firstVector:Vector.<String> = new Vector.<String>;
    var secondVector:Vector.<String> = new Vector.<String>;
    
    firstVector.push("foo");
    firstVector.push("bar");
    // firstVector now contains foo,bar
    
    secondVector.push("baz");
    // secondVector now contains baz
    
    firstVector = secondVector;
    // firstVector now contains baz
    

    'Foo' and 'bar' exist in memory somewhere now?  In other languges such as Objective-C, if the first vector cannot be erased first before being assigned the second vector data, the first vector data, then that is not accessible, still exist in memory.

    Thank you!


    I think that they stayed in the memory, but we can't reach them because they do not have a reference variable.

    in java, we know that the String class is immutable.

    ArrayList - vector in AS3 - is also immutable too.

    so when the flash vm excute the first line:

    1 - vm will create two ref first, vm and the second table set the size for them like it by default size

    2 - the vm will creat a new string 'toto' in reference 0 of the firstarray - you learned in Assembly.

    3 - Add a new string 'bar' in 1 side firstArray address in memory

    4. new 'baz' and assign the secondArray mention

    the importance is here

    now when you equal first with the second, just by moving the pointer in the first table to the "baz".

    Baz has therefore two now first and second reference table

    foo and bar will remain in the memory, garbage will delete them after some time cause there are no variables that were

    You can also call garbage collection operation by:

    flash.system.System.gc ();

  • TDMS write memory leak

    I use TDMS to store test data that seems to be causing a memory leak in my (very convincingly) program. Below is a graph of the three versions of my program. Series 1 uses storing data open PDM, the data file added and closed every 5 seconds. Series 2 uses storing data PDM with a referense remaining open during operation and closed at the end 3 series written data in a CSV file. The charts show the use of LabVIEW memory each seconde.5 ~ 4 hours of a 10 hour test.

    LabVIEW 8.6.1

    Windows XP SP3

    Further explanations... when a TDMS file is opened, LabVIEW will create an index in memory structure that is used for random access to the file. The Streaming API integrated LabVIEW TDM will always create the index, even if you just write. The size of the index is not dependent on the size of the file, but on how fragmented file is. If you store a relatively small number of large blocks of data, the index will be very low. If you keep adding small amounts of data on your record, it could make big enough. A cure for this is the property of NI_MinimumBufferSize. You can set this property on a channel to the LabVIEW to a number of values of the buffer before storing. In this way, data from multiple calls to 'Write TDMS' counts as a data segment in the file. Typical values for this are 1000 or 10000. Fragmentation of files and memory footprint are reduced accordingly, but LabVIEW uses little memory for buffers.

    If all else fails and you do not have access to the file of reading while you write, you can also use the VI-based TDMS API. This will not build the structure of the index that I mentioned above, so there should be no increase in memory at all. In this case, I recommend to defragment files front of post-processing.

    Hope that helps,

    Herbert

  • Create dllmain for labview built dll

    I have a lot of labview code I want to turn it into a DLL. The dll will require some global state initialization after cleaning on process_attach and process_detach. If I was building the C code DLL, that I would create a DLLMain function to take care of this, however when I look in the properties of specifications of generation of a DLL in the LabVIEW Project Explorer, I can't find an option to set my initialsation code and stop. Note that I use LabVIEW 8.6.

    On another note, in looking at the docs for the Call library function node we're talking reminders for the reserve, cancel and abort. What does mean to 'reserve' and 'Cancel '? The description suggests that these reminders can be used for initialization and cleanup but I see not how make use of this in a context where my labview built DLL could be described as some other environment (e.g. an exe written in C).

    I'm still fairly new to LabVIEW so I apologize if I missed something obvious.

    DLLMain is VERY limited in what it can do without causing a charger global potentional lock in Windows System. The execution of LabVIEW VIs is something requiring an infrastructure that is not safe for DLLMain initialization already almost 100%. So there is no way that I can see, LabVIEW could allow you to run a specific VI at load time. And change DLLMain yourself isn't an option either, given that LabVIEW that creates on the fly for each DLL and the code is quite tricky.

    What is the problem about the design of your DLL in such a way that the user must call an initialization function explicitly before using other features in it? After all there is no global state in a LabVIEW DLL, except by functions that are loaded into memory and remain in memory for as long as you want to maintain global state. Once function initialized global X() a memory of leaves before the Y() function that references global was loaded into memory, the enitre a global state is lost and reset to the default state when loading function Y().

  • There seems to be a MAJOR problem (blocking/memory leak) in "subject: House", also known as the Firefox Start Page, at 26.0 Firefox on Windows!

    There seems to be a MAJOR problem (blocking/memory leak) in "subject: House", also known as start up Firefox, 26.0 Firefox Page, Windows!

    seen on:
    -Windows 7 x 64 machine with 12 GB of RAM and high performance CPU (core i7-920)
    -Comments Machine virtual WinXP SP3 (in Oracle VirtualBox) running on the same computer
    -Intel Atom D525 netbook with 4 GB of RAM, running Win7 x 64

    None of these machines are connected through Sync or something like that. The Firefox instance on the virtual machine is a fresh install / clean.

    The problem:
    -100% of cpu usage for 10 seconds, (util in XP) memory usage goes up to 1.7 GB
    -If "subject: House" is actually the Firefox Start Page, it blocks the computer at startup of Firefox for 10 seconds
    -If "subject: House" isn't the Firefox Start Page, startup is fine - BUT if I press the "home" on the toolbar button it loads "on: House" which causes the same question once again

    Sounds that there is a problem with one of the code snippets that are responsible. I've seen several reports on this issue.

    You can set the browser.aboutHomeSnippets.updateUrl pref an empty string on the subject: the page of config to disable loading (new) checked to see if that helps.

    You can open the topic: config page through the address bar

    You must remove the ' storage\moz-security-about + origin "folder in the folder of Firefox to delete already profile stored clips.

    You can use this button to go to the Firefox profile folder:

Maybe you are looking for