External Function memory leak

The ExternalFunction.java sample code distributed with v.2.5.16 has a memory leak.
You can see this by changing the loop to iterate a million times; eventually it runs out of memory and crashes.
(I used jdk 1.7 u2 on Windows 7.)
I tried adding explicit calls to delete() for every created Java object in the example, none of which helped.
As far as I can tell, it is simply not possible to use external functions from Java without leaking memory.
Any thoughts on this?

thanks Silviu
i create two bugs
https://bugbase.adobe.com/index.cfm?event=bug&id=3341143
https://bugbase.adobe.com/index.cfm?event=bug&id=3341146

Similar Messages

  • External interface memory leak?

    Hello,
    I am embedding the flash player inside a Visual C++
    application. My program uses the external interface extensively.
    The external interface is called several times a second ( ~20 fps )
    each time a ~1k XML string is passed to the flash player.
    During execution the program increases its memory by ~10 Mega
    each hour. I have used the Umdh tool to try to locate the problem.
    It points to the line where the container program uses the external
    interface to call a function inside the swf movie.
    Below is a typical output of the Umdh tool:
    + 3396588 ( 3405883 - 9295) 261991 allocs BackTrace12EF
    + 261276 ( 261991 - 715) BackTrace12EF allocations
    ntdll!RtlpNtMakeTemporaryKey+000074D0
    ntdll!RtlInitializeSListHead+00010D08
    ntdll!wcsncat+00000224
    FlDbg9c!DllUnregisterServer+0010261A
    FlDbg9c!DllUnregisterServer+0010263C
    FlDbg9c!DllUnregisterServer+0000F1B7
    myProgram!CZFlash::CallFunction+0000004D (c:\documents and
    settings\amit\my documents\visual studio projects\ myProgram
    \zflash\zflash.cpp, 255)
    myProgram!MainDialogProc+000012A2 (c:\documents and
    settings\amit\my documents\visual studio projects\ myProgram
    \w32\maindlg.cpp, 2324)
    USER32!GetDC+0000006D
    USER32!PrivateExtractIconExW+000002B2
    USER32!PrivateExtractIconExW+000000FE
    USER32!DefDlgProcW+00000022
    USER32!GetDC+0000006D
    USER32!GetDC+0000014F
    USER32!IsWindowUnicode+000000A1
    USER32!CallWindowProcW+0000001B
    COMCTL32!Ordinal11+00000328
    COMCTL32!RemoveWindowSubclass+0000017E
    COMCTL32!DefSubclassProc+00000046
    COMCTL32!Ordinal389+000028DF
    COMCTL32!RemoveWindowSubclass+0000017E
    COMCTL32!DefSubclassProc+00000046
    COMCTL32!Ordinal389+000028DF
    COMCTL32!RemoveWindowSubclass+0000017E
    COMCTL32!DefSubclassProc+00000046
    COMCTL32!Ordinal389+000028DF
    COMCTL32!RemoveWindowSubclass+0000017E
    COMCTL32!DefSubclassProc+00000046
    COMCTL32!Ordinal389+000028DF
    COMCTL32!RemoveWindowSubclass+0000017E
    COMCTL32!DefSubclassProc+00000046
    COMCTL32!Ordinal389+000028DF
    The System.totalMemory value of the flash player ranges from
    2.2 Mbyte to 3.2. I tried using memory leak detection software like
    IBM's Purify but couldn't find the problem.
    I also tried to disable the BSTR caching by setting the
    environment variable OANOCACHE, but the memory of my program
    continues to increase.
    Below is my C++ code. The m_iflash object is a pointer to the
    ActiveX of the flash player.
    wstring CZFlash::CallFunction(wstring call_string)
    BSTR pcall_string = SysAllocString(call_string.c_str());
    BSTR presponse = NULL;
    HRESULT status = m_iflash->CallFunction(pcall_string,
    &presponse);
    SysFreeString(pcall_string);
    if (status != S_OK)
    if (presponse != NULL)
    SysFreeString(presponse);
    return L"";
    wstring sresponse(presponse);
    SysFreeString(presponse);
    return sresponse;
    Currently the swf movie contains only action script that
    displays the System.totalMemory value and an empty function that
    the external interface calls.
    Any help will be appreciated.
    Thanks in advance,
    Amit

    Hello,
    Thanks for coming to National Instruments Discussion Forum.
    Can you give us more details about your application? Basically, I can’t find your main VI for your User Interface. Can you also give us the different steps to do to run your application and reproduce your problem?
    Generally speaking, your code on your block diagram have to be displayable in one screen.
    Benjamin R.
    R&D Software Development Manager
    http://www.fluigent.com/

  • Memory leak in JCO when calling an ABAP-function that returns larg tables

    Hello everybody,
    I think discovered a memory leak in JCO when the calling functionions that have exporting tables with large datasets. For example the ABAP-function RFC_READ_TABLE, which in this example I use to retrieve data from a table called "RSZELTTXT", which contains ~ 120000 datasets. RFC_READ_TABLE exports the data as table "DATA".
    Here a simple JUnit test:
    http://pastebin.ca/1420451
    When running it with Sun Java 1.6 with standard heap size of 64mb I get a heapsize OutOfMemory error:
    http://pastebin.ca/1420472
    Looking at the heap dump (which I unfortunately cannot post here, because of it' size), I can see that I've 65000 char[512] array objects in my heap, which don't get cleaned up. I think, each char[512] array stands for one dataset in the exporting table "DATA", since the table contains 120000 datasets, the heap is full after the first 65000 datasets are parsed. Apparently, JCO tries to read all datasets in memory instead of justing reading the dataset to which the pointer (JCoTable.setRow(i)) currently points to and releasing it from memory after the pointer moves forward ...
    Did anybody else experience this?
    Is SAP going to remove to issue in upcoming versions of JCO?
    regards Samir

    Hi,
       Check Below links
    1) How To Analyze Performance Problems JCO
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3fbea790-0201-0010-6481-8370ebc3c17d
    2) How to Avoid Memory Leaks 
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c3e598fe-0601-0010-e990-b8622840c8c2
    Salil...
    Edited by: salil chavan on Jun 2, 2009 5:21 AM

  • Memory Leak in terminateConnection() function. How to resolve it ???

    Hi,
    We are facing a memory leak issue in terminateConnection() function. Here is a sample code regarding that. We have run around 1.5 hours simultaneously and it was consuming around 250MB for this simple program. How could I resolve this problem ?
    bool test()
        string userName = "mapserver";
        string password = "a";
        string connectString = "//localhost:1521/orcl";
        string query = "SELECT GEOMETRY AS GEOM FROM AG_WATER";
        Environment *env = Environment::createEnvironment(Environment::OBJECT);
            Connection *conn;
            Statement *stmt;
            ResultSet *rs;
            try{
                conn = env->createConnection(userName, password, "");
            catch (SQLException ex) {
                printf("ORACLE execution error: [Error Code : %d] : %s\n", ex.getErrorCode(), ex.getMessage().c_str());
                return false;
            env->terminateConnection(conn);
            stmt = NULL;
            conn = NULL;
            rs = NULL;
        Environment::terminateEnvironment(env);
        return true;
    int main()
        OracleResultSet pResultSet;
        while (true) {
            test();
        return 0;
    Does any body help me to find out this problem ???

    This is not a web dynpro related question.  Please restrict the questions in this forum to the Web Dynpro ABAP topic.

  • Memory leak in Gabor spectrogram function?

    HI,
    Is anyone aware of a memory leak in the SptRealFastGaborSpectrogramEx function of the signal processing toolkit? I have version 7.0.1.  I have debugged everything else and cannot seem to find anything in my code.  
    Thanks!
    Marc

    Marc,
    I responded VIA email but I will also discuss this here.
    Since you are using a C++ environment, there may be problems with calling these functions (though technically they should work). I am unable to replicate this issue in CVI (what this toolkit is made for) however, could you try to use the non-Ex version of this function? If this still does not work, please email me a small example of this behavior in a small project and I can try to see if we can locate the problem.
    Brandon Vasquez | Software Engineer | Integration Services | National Instruments

  • Memory leak in external interface SetReturnValue?

    I'm having trouble with a memory leak in my application. I'm
    hoping someone out there can help me find a fix or workaround, or
    tell me what I'm doing wrong.
    The leak seems to be coming from the flash external
    interface; specifically, IShockwaveFlash.SetReturnValue(String). My
    application is written in Visual Basic 2008, connecting to Flash
    9.0.124.0 (activex version).
    I've written a fairly simple flash/VB program pair to
    illustrate the problem.
    The SWF contains a button, 2 dynamic text fields, and the
    ActionScript 2 code below.
    The VB project contains a Form with a AxShockwaveFlash object
    and the VB code below.
    When this program is run, and the button is clicked a lot
    (10's of thousands of times), the application's memory creeps up
    and never seems to fall back down. If the string passed to
    SetReturnValue is longer, memory is consumed faster. But if the
    call to SetReturnValue is commented-out, the application's memory
    usage remains stable.
    If anyone has any suggestions on how to proceed, I'd be
    grateful.
    (By the way: I'm using a freeware program called DoItAgain to
    automate the button pressing.)

    I have developed two simple Java and corresponding
    C++ classes. Use code tags when you post your code.
    You are missing a lot of error checking. JNI calls, every single one, will usually be followed by some sort of error checking. Any that access classes, methods, fields or allocate object must be followed by checks for java exceptions.
    You will need to reduce your code to a smaller sample. Otherwise it is unlikely anyone will look at it.
    You also need to specify how you know that a memory leak is occurring.

  • Memory leak with Power Spectrum function

    Hi
    I have a memory leak on my application. By observing with the "Desktop Execution Trace Toolkit", the Power Spectrum function (from NI_AALPro.lvlib) seems to have two "Reference leak".
    The first one refers to the function "Open VI reference"; I got around this problem by replacing the "Open VI reference" by an "Initialize" input boolean, but I don't understand the second memory leak.
    Any idea ?
    Thanks...
    (See attachments : Desktop Execution Trace + code)
    LV8.6.1 + Desktop Execution Trace Toolkit 2009
    Same problem with LV2012 + Desktop Execution Trace Toolkit 2012
    Attachments:
    DesktopExecutionTraceToolkit.png ‏82 KB
    MemoryLeakPowerSpectrum.zip ‏7 KB

    Hi Mathilde,
    Thank you for using NI Discussion Forums!
    I reproduce this problem with LV2012 + Desktop Execution Trace Toolkit 2012. I will look further into this.
    Are there many calls of this function in your code? Could it be a problem for you?
    Thank you.
    Regards,
    Audrey_P
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    Journées techniques : des fondamentaux aux dernières technologies pour la mesure et le contrôle/comm...

  • Memory leak with callback function

    Hi,
    I am fairly new to LabWindows and the ninetv library, i have mostly been working with LabVIEW.
    I am trying to create a basic (no GUI) c++ client that sets up subscriptions to several network variables publishing DAQ data from a PXI.
    The data for each variable is sent in a cluster and contains various datatypes along with a large int16 2D array for the data acquired(average array size is 100k in total, and the average time between data sent is 10ms). I have on average 10 of these DAQ variables.
    I am passing the same callback function as an arguement to all of these subscriptions(CNVCreateSubcription).
    It reads all the correct data, but i have one problem which is that i am experiencing a memory leak in the callback function that i pass to the CNVCreateSubscription.
    I have reduced the code one by one line and found the function that actually causes the memory leak, which is a CNVGetStructFields(). At this point in the program the data has still not been passed to the clients variables.
    This is a simplified version of the callback function, where i just unpack the cluster and get the data (only showing from one field in the cluster in the example, also not showing the decleration).
    The function is passed into to the subscribe function, like so:
    static void CNVCALLBACK SubscriberCallback(void * handle, CNVData data, void * callbackData);
    CNVCreateSubscriber (url.c_str(), SubscriberCallback, NULL, 0, CNVWaitForever, 0 , &subscriber);
    static void CNVCALLBACK SubscriberCallback(void * handle, CNVData data, void * callbackData)
    int16_t daqValue[100000];
    long unsigned int nDims;
    long unsigned int daqDims[2];
    CNVData fields[1];
    CNVDataType type;
    unsigned short int numFields;
    CNVGetDataType(data, &type, &nDims);
    CNVGetNumberOfStructFields (data, &numFields);
    CNVGetStructFields (data, fields, numFields); // <-------HERE IS THE PROBLEM, i can comment out the code after this point and it still causes a memory leak.
    CNVGetDataType(fields[0], &type, &nDims);
    CNVGetArrayDataDimensions(fields[0], nDims, acqDims);
    CNVGetArrayDataValue(fields[0], type, daqValue, daqDims[0]*daqDims[1]);
    CNVDisposeData(data);
    At the average settings i use all my systems memory (4GB) within one hour. 
    My question is, have any else experienced this and what could the problem/solution to this be?
    Thanks.
    Solved!
    Go to Solution.

    Of course.....if it is something i hate more than mistakes, it is obvious mistakes.
    Thank you for pointing it out, now everything works

  • Memory leak when I use function with bstr_t type

    Hello,
    I use Visual C++ 6 and TestStand 3.1.
    I use the tool: Purify from Rational Instruments to detect memory leak in my code.
    When I use in my code, functions from the TestStand API using bstr_t types: GetValString, GetType... memory leaks appear.
    Do you have an idea to solve this problem?
    Thanks

    Breizh,
    Etes vous sur que le problèmes soit lié au type bstr_r ?
    Pouvez vous me faire parvenir un exemple de code mettant en oeuvre la fuite mémoire?
    Raphaël T.
    NI FRANCE
    Cordialement,
    Raphael T

  • Memory Leak in Algorithms.Cast function?

    I have the following line in my code:
    Algorithms.Cast(OrigImage, tempRGB, ImageType.Rgb32)
    OrigImage is a U8. It appears to have a 7mb memory leak.
    Before: 81168K,
    After:    88560K
    Has anyone else noticed this? Is there a fix?
    Note: I properly dispose of all images when I am done using them.
    Thanks!

    Can you describe the situation a little bit more? What memory are you refering to when you say "Before: 81168K, After:    88560K"? Are you talking about the total amount of memory reserved by the application?
    The cast function will convert an image of one type to another. If you were going from a U8 image to an RGB 32, the new image would require about 12 times the memory as the original image. 7 Mb would be a reasonable amount of memory increase for this process.
    Jeremy P.
    Applications Engineer
    National Instruments

  • External dll call memory leak

    Hi,
    My VI calls a function in a dll in a loop for a long period of time.
    I've noticed that after couple of hours it starts loosing memory.
    It seems like the LabViews consumption of memory stays constant but the System looses memory.
    I've checked the dll in .Net application and I'm sure that there is no such a problem there.
    This is how my VI is organized:

    I don't see anything either. But can you maybe post how the dll function is declared in it's header file (with all the macro definitions if any are used in the function prototype) as well as a screenshot of the NI prototype found in the "Call library function" node.
    Can you also clarify if the RAM usage is again decreased once the application ends or if it stays at the increased level. In one case it's a memory leak while in the other case it might simply be that LabVIEW needs a lot of RAM to do whatever calculations you do with the data (although 1GB does seem like a lot).
    Matt

  • Memory leak in a function registered using set_restore_function()

    I experience a problem with memory leak caused by the following function:
    void RestorePhonemesSet(PhonemesSetStructType &phonemesSet, const void *src) {
    char p = (char ) src;
    memcpy(&phonemesSet.len, p, sizeof (int));
    p += sizeof (int);
    memcpy(&phonemesSet.whichFile, p, sizeof (int));
    p += sizeof (int);
    memcpy(&phonemesSet.whichPosition, p, sizeof (int));
    p += sizeof (int);
    phonemesSet.phonemes = (int *)malloc(sizeof(int)*phonemesSet.len);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here the problematic code
    memcpy(phonemesSet.phonemes, p, sizeof (int) * phonemesSet.len);
    This function is registered using a following call: DbstlElemTraits<PhonemesSetStructType>::instance()->set_restore_function(RestorePhonemesSet);
    The culprit it the malloc memory allocation. If I leave out the malloc the program crashes. If I free the phonemeSet.phonemes memory segment at the end of the restore function I lost data, and if I use the malloc there is a large memory leak while reading every record from the database.
    What should I do to prevent the memory leak?
    Regards,
    markur
    Edited by: 904259 on 2011-12-24 05:42

    the solution is using the memory allocated for p, no need to allocate new memory space for the variable: the problematic line should look like .phonemes = (int *)p;
    the memcpy function in the following line is thus superfluous.
    Edited by: 904259 on 2011-12-24 05:43

  • Applet calling javascript function causing memory leak

    Hi,
    I'm troubleshooting one memory leak issue in my application and to do that I created one simple Java applet and HTML + javascript function to locate the problem.
    Basically it's an applet calling a javascript function using a timer. The javascript function simply does nothing.
    I tested in IE 8.0 and JRE 1.6.0_23-b05 and memory of IE keeps increasing.
    I saw this bug http://bugs.sun.com/view_bug.do?bug_id=6857340 which seems related with my issue, but if I understand correctly from the page, the issue should have been fixed.
    I posted this message to find out if others also find same issue and if there's a solution for this. If I comment out window.call("dummy", null); , memory will not climb up.
    Java code
    +public class Main extends Applet implements Runnable  {+
    public Applet currentApplet= this ;
    +     public JSObject window = null;+
    +public void run(){+
    +          System.out.println("run..");+
    +     }+
    +public void start(){+
    window = JSObject.getWindow(this);
    int delay = 300; //milliseconds
    +ActionListener taskPerformer = new ActionListener() {+
    +public void actionPerformed(ActionEvent evt) {+
    window.call("dummy", null);
    +}+
    +};+
    new Timer(delay, taskPerformer).start();
    +     }+
    +public static void main(String[] args) {+
    +          System.out.println("start...");+
    +          Main main = new Main();+
    +     main.start();+
    +     }+
    +}+
    Javascript source code
    +<html>+
    +<head>+
    +<script>+
    +function dummy() {+
    +     +
    +}+
    +</script>+
    +</head>+
    +<body>+
    +<applet .... >+
    +...+
    +</html>+

    Try this url:
    http://www.inquiry.com/techtips/java_pro/10MinuteSolutions/callingJavaScript.asp
    It also provides some examples.

  • Plugin-container.exe takes over and uses 100% of my CPU locking me out and leaving my PC non-functioning. Is this a bug, or a memory leak, in the Firefox software? Can anything be done to fix this problem?

    In looking at Windows Task Manager I found that plugin-container.exe was taking over 100% of my CPU and my system was frozen. Is this a memory leak or other bug?

    Thank you! I have been having problems with Adobe Flash since downloading the new 11.1 version. I will download it again and reinstall it, hopefully that will correct the problem.

  • Memory leak when passing variables to functions in StarOffice Basic

    The following code generates a fast memory leak:
    Sub Main
    Dim i&
         for i = 1 to 1000000
              Model(i)
         next i
    End Sub
    Sub Model(j&)
         j = j
    End Sub
    But if you put the contents of Sub Model into Main, or if you make j a public variable and don't pass it explicitly to Model, the memory leak disappears.
    Message was edited by:
    capnbob

    That's a bit different for event handlers like the onRelease
    event of buttons.
    mybutton.onRelease = myfunction(1); -> the code will
    execute right away without waiting for the event to fire
    mybutton.onRelease = myfunction(); -> the code will
    execute right away without waiting for the event to fire
    mybutton.onRelease = myfunction; -> myfunction gets called
    after the event onRelease fires.
    See attached code.

Maybe you are looking for