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.

Similar Messages

  • Does call to ptsname() cause memory leak?

    Purify signalled that the call to ptsname() is a memory leak. ptsname() returns a char* and
    apparently is doing this on the heap even though the man page says it is a static data area. My
    question is whether we need to do a free() on the return from ptsname()?

    I believe that there was a memory leak problem with DataSocket 3.0 which came with LabVIEW 5.1. Try upgrading DataSocket to 4.0.
    http://digital.ni.com/softlib.nsf/web%2Fall%20software?OpenView&Start=1&Count=500&Expand=6#6
    If that does not work, the problem may not have been resolved until LabVIEW 6. Also, if you happened to be using the French version of LabVIEW, contact tech support, there was a specific problem there which does have a work around.

  • Calling SetLocalTime in C# causes Memory Leak (WEC7)

    Hello,
    I use SetLocalTime() in C#. Everything works well if I start explorer.exe and my application. But if I don't start explorer.exe at system start. SetLocalTime() causes memory leak in my application. I call the function frequently every hour.
    public static bool SetzeLokalZeit(SYSTEMDATETIME lpSystemTime)
    #if DEADLOCKDETECT
    using (DdMonitor.Lock(MyTimeLock, "MyTimeLock#1"))
    #else
    lock (MyTimeLock)
    #endif
    bool ret = false; // no Success
    try
    GLB.LogFile.MyWrite("SetLocalTime");
    SYSTEMDATETIME loc = new SYSTEMDATETIME();
    loc.wYear = lpSystemTime.wYear;
    loc.wMonth = lpSystemTime.wMonth;
    loc.wDayOfWeek = lpSystemTime.wDayOfWeek;
    loc.wDay = lpSystemTime.wDay;
    loc.wHour = lpSystemTime.wHour;
    loc.wMinute = lpSystemTime.wMinute;
    loc.wSecond = lpSystemTime.wSecond;
    loc.wMilliseconds = lpSystemTime.wMilliseconds;
    ret = SetLocalTime(ref loc);
    if (!ret) // no Success
    int err = Marshal.GetLastWin32Error();
    if (err > 0)
    GLB.LogFile.MyWrite("ERROR CODE:" + err.ToString());
    else ret = true;
    catch (Exception ex)
    GLB.LogFile.MyWrite("000023 Exception" + ex.Message);
    finally
    GLB.LogFile.MyWrite("SetLocalTime Ende");
    return ret;
    Has someone an idea what's the problem?
    Best regards,
    Andreas

    Hello,
    Here the answers to the questions:
    1. Does the SetLocalTime function succeed?
    Calling SetLocalTime doesn't cause an exception an the local time is set correctly.
    2. Do you still get the memory leak if you remove all other calls?
    Yes. I have removed any other code, but I also get the memory leak.
    3. Does the memory leak also occur when you do this from native code?
    I have not tried it yet. But I will still make it...
    [DllImport("coredll.dll")]
    private static extern void GetLocalTime(ref SYSTEMDATETIME lpSystemTime);
    [DllImport("coredll.dll", SetLastError = true)]
    private static extern bool SetLocalTime(ref SYSTEMDATETIME lpSystemTime);
    [StructLayout(LayoutKind.Sequential)]
    public struct SYSTEMDATETIME
    public ushort wYear;
    public ushort wMonth;
    public ushort wDayOfWeek;
    public ushort wDay;
    public ushort wHour;
    public ushort wMinute;
    public ushort wSecond;
    public ushort wMilliseconds;
    public static bool Pub_SetLocalTime(SYSTEMDATETIME lpSystemTime)
    lock (MyTimeLock)
    bool ret = false; // no Success
    try
    loc_set.wYear = lpSystemTime.wYear;
    loc_set.wMonth = lpSystemTime.wMonth;
    loc_set.wDayOfWeek = lpSystemTime.wDayOfWeek;
    loc_set.wDay = lpSystemTime.wDay;
    loc_set.wHour = lpSystemTime.wHour;
    loc_set.wMinute = lpSystemTime.wMinute;
    loc_set.wSecond = lpSystemTime.wSecond;
    loc_set.wMilliseconds = lpSystemTime.wMilliseconds;
    ret = SetLocalTime(ref loc_set);
    if (!ret) // no Success
    int err = Marshal.GetLastWin32Error();
    if (err > 0)
    MessageBox.Show("Win32 Error:", err.ToString());
    else ret = true;
    catch (Exception ex)
    MessageBox.Show("SetLocalTime,Exception:", ex.ToString());
    finally
    return ret;
    Best regards,
    Andreas

  • Java Applet call javascript problem

    Hi I have a web page as follow and embedded a applet. The applet call the java script, and instead of showing an alarm, the browser show the javascript code. Is that strange ? Any suggestion for this problem.
    HTML:
    ================================================================
    <HTML>
         <HEAD>
         function ShowEmbd()
              alert("Test Applet call Javascript");
         </SCRIPT>
         </HEAD>
         <BODY>
         <FORM NAME="AppletEmbdStart">
              <OBJECT classid="clsid:48B2DD7B-6B52-4DB0-97C9-ECB940113B47" id="CIVON_DEmbdObj" width="0" height="0"></OBJECT>
              <APPLET code="MyApplet.class" width="0" height="0"></APPLET>
         </FORM>
         </BODY>
    </HTML>MyApplet.java
    =========================================================================
    import netscape.javascript.*;
    public class MyApplet extends javax.swing.JApplet
         private JSObject m_win = null;
         private JSObject m_doc = null;
         public void init()
              getJSWin().call("ShowEmbd", null);
         private getJSDoc()
              if(m_doc == bull)
                   m_doc = (JSObject) getJSWin().getMember("document");
              return m_doc;
         private JSObject getJSWin()
              if (m_win == null)
                   m_win = netscape.javascript.JSObject.getWindow(this);
              return m_win;
    }The page was load and it should call the applet MyApplet. The MyApplet should do the init() method and call the Javascript "ShowEmbd()", BUT, instead of show alert from ShowEmbd(), the browser show the code of ShowEmbd() itself ...... It did not run the javascript and shows the alert ??
    The browser shows a message from status bar "The applet not initial" ???? why ???
    Can anyone help ?!

    On first look:
    I am not sure about the Object Tag, but the Applet Tag requires the MAYSCRIPT attribute before Java can call Javascript.

  • SetObjectArrayElement causes memory leak

    Hello There,
    I have got a little problem that I'm not able to solve for myself. Look at this piece of
    JNI code:
    double** result = calculator->getResult();
    jobjectArray table = env->NewObjectArray(height, env->FindClass("[D"), 0);
    for (int i = 0;i < height;i++) {
         jdoubleArray row = env->NewDoubleArray(width);
         env->SetDoubleArrayRegion(row, 0, width, (jdouble*)result);
         env->SetObjectArrayElement(table, i, row);
         env->DeleteLocalRef(row);
    This fragment causes a memory leak , but if I omit the env->SetObjectArrayElement(table, i, row);
    call, there is no memory leak. I don't really know what exactly causes this memory leak and how
    to fix it. Any help would be greatly appreciated ;-)
    Michael                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Ok I think the code snippet I posted was not complete...
    double** result = calculator->getResult();
    jobjectArray table = env->NewObjectArray(height, env->FindClass("[D"), 0);
    for (int i = 0;i < height;i++) {
         jdoubleArray row = env->NewDoubleArray(width);
         env->SetDoubleArrayRegion(row, 0, width, (jdouble*)result);
         env->SetObjectArrayElement(table, i, row);
         env->DeleteLocalRef(row);
    jobject rawData = env->NewObject(classreg["data/rawdata1d"], methodIDreg["data/rawdata1d/init"], width, height);
    env->SetObjectField(rawData, fieldIDreg["data/rawdata1d/data"], table);
    return rawData;
    The array I create is set as a member of a Java object which
    is then returned by the native method. As long as this object
    is in use by my program it's clear that the memory I allocated
    for the array never gets released. But when the Java object is
    no longer used by my program and the garbage collector releases
    the memory occupied by this object, shouldn't it release the memory
    occupied by the array I created in my native method too? Apparently
    this is not the case, do I have to release the Java array for myself?
    Michael
    Edited by: Michael_JavaAddict on Aug 25, 2010 3:03 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to call javascript function in back bean of jsf

    hi,
    i am trying to call java script function in back bean but not done. Is there any code for call javascript function in bean file.

    Java runs at server side.
    JSF produces HTML output.
    Server sends HTML output to client.
    Java stops running.
    HTML runs at client side.
    JS starts to run in HTML.
    Clear? Java is a server side language. JS is a client side language. To run JS using JSF, simply print it out to the HTML so that it get invoked when the HTML runs.

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • JSF: partial page rendering is causing memory leak leading to outofmemory

    JDeveloper 10.1.3.2.0
    JDK: 1.6.0_06
    Operating System: Windows XP.
    I test my application for memory leaks. For that purpose, I use jconsole to monitor java heap space. I have an edit page that has two dependent list components. One displays all countries and the other displays cities of the selected country.
    I noticed java heap space keeps growing as I change country from country list.
    I run garbage collection and memory usage does not go down. If I keep changing the province for 5 minutes, then I hit a java heap space outofmemory exception.
    To narrow down the problem, I removed the second city component and the problem still exists.
    To narrow it down further, I removed autosubmit attribute from the country component and then memory usage stopped increasing as I change country.
    country/city partial page rendering is just an example. I am able to reproduce the same problem on every page where i use partial page rendering. My conclusion is PPR is causing memory leak or at least the autosubmit attribute.
    This is really bad. Anyone out there experienced same issue. Any help/advice is highly appreciated !!
    Thanks
    <af:panelLabelAndMessage
    inlineStyle="font-weight:bold;"
    label="Country:"
    tip=" "
    showRequired="true"
    for="CountryId">
    <af:selectOneChoice id="CountryId"
                   valuePassThru="true"
                   value="#{bindings.CountryId.inputValue}"
                   autoSubmit="true"
                   inlineStyle="width:221px"
                   simple="true">
         <af:forEach var="item"
              items="#{bindings.CountriesListIterator.allRowsInRange}">
         <af:selectItem value="#{item.countryId}"
                   label="#{item.countryName}"/>
         </af:forEach>
    </af:selectOneChoice>
    </af:panelLabelAndMessage>
    <af:panelLabelAndMessage
    inlineStyle="font-weight:bold;"
    label="City:"
    tip=" "
    showRequired="true"
    for="CityId">
    <af:selectOneChoice id="CityId"
                   valuePassThru="true"
                   value="#{bindings.CityId.inputValue}"
                   partialTriggers="CountryId"
                   autoSubmit="true"
                   inlineStyle="width:221px"
                   unselectedLabel="--Select City--"
                   simple="true">
         <f:selectItems value="#{backing_CountryCityBean.citiesSelectItems}"/>
    </af:selectOneChoice>
    </af:panelLabelAndMessage>

    Samsam,
    I haven't seen this problem myself, no.
    To clarify - are you seeing this behaviour when running your app in JDeveloper, or when running in an application server? If in JDeveloper, a copuple of suggestions:
    * (may not matter, but...) It's not supported to run JDev 10g with JDK 6
    * have you tried the [url http://www.oracle.com/technology/pub/articles/masterj2ee/j2ee_wk11.html]memory profiler
    Best,
    John

  • How to call javascript function in Flash

    Please help...
    I have a site that run multiple of domain for example
    Domain (A): raymond.com
    Domain (B): raymond.ca
    The problem is this.. when (B) html page load the flash file
    that locate at (A) it load but non of the buttons work which call
    javascript function using getURL("javascript:showpopup()"); But it
    work fine if all reside on the same domain,eg( (A) html page load
    flash file form (A)). Anyone know how to solve this other than
    create a set of flash files on (B).
    Regards,
    Raymond

    http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?cont ext=Flash_MX_2004&file=00001750.html

  • Call javascript function dynamically

    Can this be done to call Javascript function dynamically? What I mean is suppose I use Javascript to submit form and target the reply to a popup window:
      function cForm() {
         win=window.open('','myWin','toolbars=0');
         document.aForm.q.value='12345';     
         document.aForm.target='myWin';
         document.aForm.submit();
      }I target the form reply to popup window myWin. Suppose the reply body contains some Javascript function doX(). Is it possible to call doX() automatically, after the submit and the reply is loaded on myWin, maybe using some onload event in the popup window?

    On the PopUo Windows BODY onLoad, call the method doX()

  • Call javascript function after submit process

    Hi,
    How can I call javascript function after my submit process ?
    Thanks.

    Hi Carl,
    You say that I must have an Item or region that contains my js with conditionnal display. With this method I can execute my js with specific request value.
    My problem is that I tried to integrate the "save large value workaround" in my application with the APEX wysiwyg (fckeditor). To do that I have to call the javascript function clob_submit on the save button. This function save the value of my field but if I want to save other item value, how can I do that ?
    If I use your method, I will submit the page, save the other field and after that, I will branch on the same page. At this moment, I will execute my javascript file.
    Is it what did you said ?
    Sylvain Michaud
    Homepage : http://www.insum.ca
    InSum Solutions' blog : http://insum-apex.blogspot.com

  • How can i call javascript function with out internet connection?

    I have trying to call javascript function through ExternalInterface. But flash player recomonding to have internet connectivity. i have allredy used allowscript="always" .

    first, allow the folder that contains your flash files to connect to the internet by adjusting your security settings:
    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.ht ml
    then try the following in a swf and open the published html in your browser to test:
    import flash.external.ExternalInterface
    ExternalInterface.call("function(){alert('test');}")

  • Call JavaScript function from Acrobat Plugin

    Hi All,
    I want to call JavaScript function from Acrobat Plugin? Where is to write JavaScript function in Acrobat SDK? Please reply..
    Thanks in advance..

    Hi Malkyt,
    Thanks.. where is to write JavaScript code in the application..
    function GetWelcome()
    alert("Welcome");
    this above code. how to use this javascript code to plugin application.
    static ACCB1 ASBool ACCB2 AVPageViewMouseClick (AVPageView pageView, AVDevCoord xhit, AVDevCoord yhit, AVFlagBits16 flags, AVTCount clickNo, void *data)
    char jsscript[200];
    AFExecuteThisScript (pddoc, jsscript, NULL);
    i want to display welcome message of JS file.. give me step to perform above task.. Please reply...

  • IPad = webStageView = HTML = call javascript function thru Flash

    Has anyone loaded a HTML file thru webStageView, and then been able to call javascript functions embeded in the HTML through flash.
    I've seen references to using webStageViewBRIDGE but I think that has been depreciated.
    Below is a link to a Adobe tutorial doing this with the htmlLoader class and FLEX.
    Cross-scripting PDF content in an Adobe AIR application
    http://www.adobe.com/devnet/air/flex/quickstart/articles/scripting_pdf.html
    If anyone has successfully been able to do this on the iPad, could you explain how it's done or provide a link to some documentation.
    Thanks...

    Stagewebviewbridge is a 3rd party library (not an official Adobe product). It looks like it is still supported. The technique described should work even if the library isn't being actively developed.
    http://code.google.com/p/stagewebviewbridge/wiki/Communication
    Also, note that most techniques which use the HTMLLoader class will not work with the StageWebView class -- they are entirely different beasts. (Well, to be precise, on desktop computers, StageWebView uses the same Webkit code, but the interface to it is still very different.)

  • Can Java program cause memory leak?

    Can Java program cause memory leak or memory crash? I don't mean any memory overflow related exceptions. I mean something like core dump in UNIX or error reports in Windows XP.
    If it can really happen, in what circumstances? I raise such a question because our J2EE based system had really caused memory leak in Windows XP systems, but so far we still fail to troubleshoot the problem.

    Your code may leak memory. There are many, many, many reasons this could be. All of them represent bugs in your code.
    You should get a profiler to identify the problem spots of your code.
    You spoke of a memory crash as well. The VM may crash with some bug in the VM, or a bug in native code but that is not relevent to your problem. A memory leak is a problem in your code.

Maybe you are looking for

  • How to get Header data into multiple times along with the Line Items

    Dear All,   I have problem while mapping the Header data and line item data to the flat file structure, Header data have to repeat along with the Line item data in the flatfile. Details is below. Example Header record is one E1EDK01 E1EDKA1 Line item

  • How to copy game data from one device to another

    I downloaded Injustice: Gods Among Us onto an iPhone 5 and I wanted to have all of my save data copied onto the iPhone 5. The same iCloud account is used on both devices and I recently backed up my iPhone 4. I want to know how to copy (if there is a

  • Credit Card Charged Multiple Times When Ordering Photo Book

    I had difficulty ordering a photo book. After reading through your support pages I figured out how to do it after trying 8 times - it kept crashing. Today, I look at my credit card statement and i've been charged 8 times even though it only went thro

  • Can't download music that I bought

    I downloaded now 85 on my mini ipad with my Apple ID, after the download I started to play some music but suddenly my mini ipad automatically turned off,  I then turned it on again and went to play my last purchase but it wouldn't let me play any mus

  • Look and feel master detail form

    Hello i have difficulties at the time of trying to decorate a master detail form i have 2 blocks one is the master and the other is the detail the question is can i change the text item of the master which are in the same tab canvas that the detail t