Event in JRE before OutOfMemoryError occurres

Hi!
We are developing client applications which should extensively cache server content to reduce server round-trips.
When we do caching of course the client will consume a bit of java heap memory for this.
To prevent OutOfMemoryError troubles in the client we would like to flush data from our memory cache as soon as the java heap gets exhausted and we want to prevent Errors or Exceptions being thrown.
Is there a possibility to generate / receive events in the client logic / application logic to flush data BEFORE problems are occurring?
The only workaround which I have found so far is polling if heap gets exhausted and then flush ourself - but this would lead to increased polling on memory parameters and will not guarantee to prevent problems.
Any other idea of how this could be achieved?
Thanks!

Check out the java.lang.ref package, and the WeakHashMap. For your specific purposes, I think you want soft references rather than weak references, but that should give you a starting point.

Similar Messages

  • How to capture events for movies before they load

    I'm looking for some advice from an experience action
    scripter here....am i going about this the right way?
    i have a MAIN.swf that has two movie placeholders on it, MC1
    and MC2. Depending on the context, I load different SWFs into MC1
    and MC2. They are usually datagrids and stuff. In one case, I load
    the same SWF into both movieclips. The idea is to re-use code
    rather than having a million SWFs that basically do the same thing.
    The problem i'm having is that i want to allow drag and drop
    of the data in MC2 onto MC1 and have MC1 respond accordingly. This
    is a problem because I cannot refer to components in a movie before
    it has been loaded. I am not certain (please correct me) but I
    believe that you can't do this:
    MC1.onLoad = function() {
    trace('MC1 loaded');
    MC1.loadMovie("1.swf");
    the reason being that your onLoad function is immediately
    obliterated when you load the movie. As I understand it this also
    is not possible becaus the movie might onLoad event might fire
    before you've defined your onload function:
    MC1.loadMovie("1.swf");
    MC1.onLoad = function() {
    trace('MC1 loaded');
    I'm currently handling this by putting a setup function in
    MC1 and MC2 depending on what I want the interaction between the
    two movies to be. something like this:
    // this is in MAIN.SWF
    MC1.content_mc.loadMovie("1.swf");
    MC1.setupFN = function() {
    // 'this' now refers to MC1
    this.gridListener = new Object;
    this.gridListener.change = function(evt) {
    var gs
    bject = evt.target.selectedItem;
    // LOAD DATA INTO OBJECT IN MAIN.SWF
    this.content_mc.dataGrid.addEventListener("change",
    this.gridListener);
    then inside 1.swf, I have this in the first frame which
    assigns event handlers to my data objects.
    this._parent.setupFN();
    This basically works. even if I load the same swf file into
    MC1.content_mc and MC2.content_mc, i can assign different event
    handlers to dataGrid in each instance of the same SWF.
    HOWEVER I HAVE THIS PROBLEM
    That the setupFN() function in MC1 needs to refer to objects
    in MC2 and vice versa and i have no guarantees about which might
    get loaded first. Race conditions!
    Is there some simpler way to do this? Can these setup
    functions assign event handlers to objects that haven't yet been
    instantiated? Do I need to set some kind of signal?
    Complicating matters is that in one case, when a movie gets
    reloaded, it was piling up numerous listeners so that a mouseup
    might execute the same function 10 times!
    Any advice would be much appreciated.

    That is basically what I am doing, except that MC1 and MC2
    *are* the parent clips of a movie called content_mc inside each of
    them. My problem is that the movie getting loaded into
    MC1.content_mc has to refer to a component in the SWF that is
    getting loaded into MC2.content_mc and vice-versa.
    I need the MC1.setup function and the MC2.setup functions to
    run ONLY when both MC1.content_mc and MC2.content_mc are *both*
    loaded.
    Either that or I need to be able to create an event handler
    for a component that has not yet been loaded. Is there a way to
    refer to a component in a movie before you are sure that it has
    been loaded?

  • Move iMovie event to DVD before editing for storage

    Hello,
    I need to move a few iMovie events to DVD before editing to free up some space on my MBP. I'm making room for a live AV recording and have no idea how much space I will need. Will moving the event cause any problems? How is an event burned to DVD? I saw no options to do this (or move it to another HD) in any way.
    ThankU,
    DarrellSY

    I am very sorry. I misread your original post.
    You could maybe save it as a Data DVD, if your event is smaller than 4GB (or 8GB if you do a double layer DVD).
    In Toast, create a Data DVD and drag these files in.
    In iDVD, you can look up the instructions for creating a DVD ROM. Normally, you would burn your movie so you could view it on a regular DVD, then add the files you used to make it to the DVD ROM part.
    Finally, you can create a burn folder on your Desktop, and burn to a DVD from there. That is probably the simplest way. it has been a while since I have done it, so maybe someone else can give you the step by step.

  • What is the event to handle before leaving the page?

    Hello All,
    I am using splitApp. I have a scenario where user can edit few fields in one of the "Detail" page. When user clicks some item in master page, before changing the detail page I want to show a popup to user if changes should be saved.
    Is there an event where I get to know any detail page navigation? or some event to handle before leaving the page.
    Thanks,
    Rashmi

    Hi Rashmi,
    It depends on which element you are using.
    Suppose you are using sap.ui.commons.TextField where you are editing your data(In Detail View) then change event is triggered whenever the text in the field has changed AND the focus leaves the TextField or the Enter key is pressed and you can use this event in your code according to your need.
    Here you may set some global variable and check that value if it is set or not.
    Best Regards
    Dhananjay

  • Download correct JRE before launching the jnlp application

    Hi,
    I have this requirement that before launching the jnlp application, the code should check the version of JRE installed on client's system, if it is less than 1.6 u10 then install the latest available JRE before launching the application.
    I am using the Java Script in my jsp to achieve this objective and it is working fine with non-IE web browsers. The trouble starts when the client machine is using 1.6.0_6 jre, in that case IE is not able to download /redirect user to the sun's page for the download of latest JRE.
    My java script code as follows:
    <script language="JavaScript">
    var launch = null;
    // try to check the JRE version installed on client's machine.
    //if its less than 1.6.10 redirect to Sun Micro systems website.
    //and then after installation, launch Receptionst and Call Center application
    function checkForInstalledJreVersionAndLaunch(appName)
         //detect browser used at client's machine
         var windowsIE = (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1);
         if (windowsIE) {
              alert(windowsIE);
             document.write("<OBJECT codeBase=\"http://java.sun.com/update/1.6.0/jinstall-6u10-windows-i586.cab#Version=6,0,10,0\" classid=\"clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284\" height=0 width=0>");
             document.write("<PARAM name=app VALUE=\"http://localhost:8080/"+appName+"/launch.jnlp\">");
              document.write("<PARAM NAME=back VALUE=true>");
              document.write("</OBJECT>");
         }else{
              if (navigator.mimeTypes && navigator.mimeTypes.length)
                   if(!checkWebStartWersion())
                        window.open("http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com","needdownload");
                   launch = setInterval('launchJNLP("http://localhost:8080/'+appName+'/launch.jnlp")',100);
    function launchJNLP(app) {
        if (checkWebStartWersion()) {
            clearInterval(launch);
            window.location = app;
    function checkWebStartWersion()
         var isMajorVersion = false;
         var isMinorVersion = false;
         navigator.plugins.refresh(true);
         if(navigator.mimeTypes['application/x-java-jnlp-file'])
              for(var i=0;i <navigator.mimeTypes.length; i++)
                   var pluginType = navigator.mimeTypes.type;
                   if(pluginType.indexOf("x-java-applet;jpi-version") > -1)
                        var jreVersion = pluginType.substring(pluginType.indexOf("_")+1,pluginType.length);
                        var jreUpdateNumber = parseInt(jreVersion);
                        if(jreUpdateNumber >= 10)
                             isMinorVersion = true;
                   if(pluginType.indexOf("x-java-applet;version") > -1)
                        var jreVersion = pluginType.substring(pluginType.indexOf(".")+1,pluginType.length);
                        var jreUpdateNumber = parseInt(jreVersion);
                        if(jreUpdateNumber >=6)
                             isMajorVersion = true;
         return (isMajorVersion && isMinorVersion);
    function launchApplication()
         checkForInstalledJreVersionAndLaunch("appname");
    </script>

    I hear your frustration. I am attempting to do something similar.
    To me, it looks like this ActiveX control has no ability to detect a minor version of JRE. It knows if some JRE 1.6 is installed or not, but not if say JRE 1.6.0_10 or higher is installed. But, if it finds that some JRE less than 1.6 is installed such as a 1.5 version, this ActiveX control can automatically install the latest JRE 1.6.0_12. This seems to work well for me. But, the overall behavior is not consistent. It looks to me that this ActiveX control is only good for making sure that the client has some version of JRE 1.6. It doesn't care which one.
    A similar issue exists if you try to use Java WebStart to automatically download the correct JRE 1.6 version.
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" />As of today, this code will tell Java WebStart that it needs some version of JRE 1.6 or higher to run your app. If the client does not have it, Java WebStart will download and install 1.6.0_07. Apparently, WebStart thinks that version is a "good" one - whatever that means.
    If instead you use this in your .jnlp file:
    <j2se version="1.6.0_10+" href="http://java.sun.com/products/autodl/j2se" />Java WebStart will not run your application unless the client has at least 1.6.0_10 installed. However, it is not able to install this version if the client does not have at least 1.6.0_10 already installed. It isn't smart enough for that. It looks like no one at sun has gotten around to updating http://java.sun.com/products/autodl/j2se to deal with recent JREs.
    Maybe I'm missing something, but WebStart deployment is more difficult than it needs to be. Sun introduces all sorts of new things into minor versions of Java, but nobody seems to be interested in making sure that the end user can have seemless upgrade experience.
    And people wonder why Flash and AJAX have become so popular...
    There probably is another workaround using a Java applet to determine what version is really installed before launching WebStart, but it just seems like an ugly hack to me. If an older version of Java 1.6 is detected, you could direct the user to java.sun.com in a new browser window, just as in the case of Firefox in your code. Ugly, but it would probably work.

  • 3GS only showing recurring events on calendar before 9/23/12 but all events are showing in icloud and on laptop.

    Discovered my 3GS no longer shows on the calendar nonrepeating events before 9/23/12. However, those events show in icloud and on my laptop. We tried reloading icloud but still missing. Guess is due to downloading of IOS6 - if so, why didn't Apple let us know we couldn't download upgrade to 3GS?  Also, will be ordering Iphone 5 and want to ensure have ALL calendar etc. downloaded.  Can it be done using the 3GS in the store or will I have to  take home and do with laptop?

    Did you try going to Settings>iCloud and turning Calendars to Off and when it asks if you want to keep the data, declining?  This will erase the calendar from your phone but not from iCloud.  Then, after waiting a minute or so,  turn Calendars back to On, and if prompted, choose Merge to redownload your calendar.

  • Contextual event - handler called before producer bean's setter

    I am trying a simple contextual events usecase:
    Page A.jsff has an input text field whose value is directly stored in a bean variable (bean is in pageFlowScope). Contextual event is defined on value change event for this input field. A.jsff has taskflow B_btf as an embedded region.This B_btf will simply display the value entered in the A.jsff. So, when contextual event is raised, the handler sets the value in a local variable of B_btf bean. The problem is that the handler method is getting called before the setter for the attribute of the bean of A.jsff. This is resulting in the B_btf displaying the last-but-one value entered in the input field of A.jsff instead of the current/latest value. Any tips?
    Thanks,
    Amitabh

    The issue was with the (lack of) understanding of the JSF lifecycle. The value change listener is called during the Process Validation phase, whereas the managed bean (Model) values will be set in the Update Model phase which lies next-in-line after Process Validation phase. Hence, if the value change listener is to be used, then the handler code should have used the default payload and not the custom payload. For a value change event the default payLoad will be a DCBindingContainerValueChangeEvent, and one can invoke getNewValue() to get the value entered in the text field (For details watch Frank Nimphius' video here: ADF Region Interaction - Contextual Events - YouTube). For my case, I added a command button to the page, and moved the contextual event to that button.

  • Should I uninstall the jre before I install the sdk?

    I'm wondering what the best practice is here. I've had the jre 1.4.1_01 plugin installed and working fine with Mozilla 1.2.1.
    Should I uninstall it before I install the sdk? I really don't want any conflicts but I'm sure if the jre in the sdk is for the sdk's use or if I can use it in my web browser as well.
    Thanks.
    sb

    i you uninstall or not it doesn't matter, your sdk will jus work fine. But in the browser you got to select which jre you want to use.
    Bye
    -Dani

  • Code to wait until one event is finished before starting another?

    Hi all,
    Coding isn't my strong point but I have a basic understanding of how functions etc work.
    I've been learning about referencing symbol timelines with the awesome tutorial from the Adobe Blog, included below.
    http://blogs.adobe.com/edge/2012/07/18/tutorial-leveraging-independent-symbol-timelines/
    I've been able to get my symbol to play from a certain part of it's timeline depending on whether the mouse is rolling in or out but now I'm a little bit stuck.
    The mouseover event triggers an animation and the mouseout triggers another animation that starts from the same frame that the mouseover animation ends with.
    The problem is this. If I move the mouse quickly over the buttons, the first animation will play halfway through and when the mouseout triggers the second animation, the first animation will seemingly "skip" to the ending and move straight to the first frame of the second animation.
    I know enough to code it so that the second animation will check if the first animation is still playing before starting by using an else/if statement. Using this method I only know how to skip the second animation if the first is playing but that isn't really what I'm looking to do.
    Here comes the question; can anyone explain to me how to create a wait loop in Edge Animate?
    When I say wait loop, I am talking about code that will check a variable and perform an action if the variable is true OR loop back to the start of the function if the variable is false (to check the variable again).
    The behavior I am trying to achieve is somewhat like queuing the second animation so that it will "wait" until the first animation is played before beginning the second animation.
    Any ideas?

    Ok Mr Doon,
    Clearly, I read to quickly
    The behavior I am trying to achieve is somewhat like queuing the second animation so that it will "wait" until the first animation is played before beginning the second animation.
    So, say the anima symbol is a 2s animation and has autoPlay set to false. There are two instances anima-1 and anima-2 on stage.
    The event handler anima-1.mouseover starts the first animation :
    We select Stage in the code panel and place before the first Symbol.bind… the declaration for two symbol (stage) variables :
    Inside the anima timeline, click the top left bullet+curly brackets icon and select complete : when the animation is complete, we set the boolean variable (what is not very clean here is that this is done for the two instances anima-1 and anima-2) :
    The event handler anima-2.mouseover starts the wait loop, by calling a function defined at the stage level :
    More precisely, the function is defined in the document.compositionready handler. It defines (and stores in variable waitLoop in order to be able to remove when finished) an interval, that is the repeated call, every 10 ms, of an inner anonymous function.
    The latter simply tests the boolean and when its true
    - starts the second animation ;
    - clears the interval.
    You can download the example here : https://www.box.com/s/6yxjfmrqd0b5zbhmd3lx
    You can hover over the left rounded rectangle, and immediately after over the second one. Subsequent rollovers are not handled, but it gives you a possible logic to adapt to your particuliar problem (that I still do not understand completely : it's hard without seeing).
    Gil

  • What EVENT triggers, just before coming out from adobe?

    Hello
    For some reason we don not want to use Adobe's COMMENTS part.
    So, we want to keep 2 text fields, 1st is for comments histiry(readOnly) and 2nd is to write comments, so, i kept 2 text fields with MULTIPLE LINES option, fine.
    We do not have any SUBMIT or any other button on the form. Instead we are using some other button (its nothing doing with Adobe, its not on the form, its outside of adobe) to process it.
    So, as soon as user clicks this out_side_adobe_button, i need to do the following,
    - check is user entred any comments?
    - if so, transfer that to commentary_history field
    - when user open the same form, user will see his prevoous comment in history field and he can write another comment in 2nf field.
    Pls. let me know What is the CORRECT EVENT to get it done? i tried PRE-SAVE but, did not worked!
    If possible the code pls.
    Thank you

    Any help pls?
    THank you

  • TS3999 ical keeps deleting all my events the day before the event!

    My ical keep deleting all my events the day defore the event and or on the day of the event!  Any one having this problem or know how to fix it?  thanks

    Give this a try
    http://qgf.in/11Bc6Z

  • HT4504 Setting an event in iCal before traveling

    I am in the central time zone. I will be traveling to Chile. I enter my flight home from Chile at 11:40pm on the day of travel and select Santiago, Chile time. When I look at it in my calendar while still at home it says 8:40pm. When I am in Chile, will it adjust back to 11:40pm so I am not three hours early?

    Those are the last two alarms you set. It remembers the last 5 or so. Like a recent history. Set a new alarm and that will appear at the top of that list.
    Regards,
    Captfred

  • Event triggerred before Wait step

    What can we do when the event is triggerred before the wait step? Does anyone know about the concept of parked events?
    Iam using f.m swe_event_create, can we use the start_with_delay option or some other option..
    I would like to have some delay before the second event is raised. but at the same time as this would be a online program, the user should not feel the delay..
    or the Wait step should be modified to pick up already created events..(i think this is called parked events).
    CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
    *objtype =
    *objkey =
    *event =
    CREATOR = ' '
    TAKE_WORKITEM_REQUESTER = ' '
    START_WITH_DELAY = ' '
    START_RECFB_SYNCHRON = ' '
    NO_COMMIT_FOR_QUEUE = ' '
    DEBUG_FLAG = ' '
    NO_LOGGING = ' '
    IDENT =
    IMPORTING

    Hi Karri, thanks for the reply ..There is a presentation on parked events if you search the wiki and blogs on this site, you will find it but thats the only thing i have seen about it and its not really helpful.
    the problem is.. 2 Inbound idocs are created both at the same time one raises a event for workflow.. one raises a event for Wait step in the same workflow ..
    The 2 inbound F.Ms which raise the events, can error sometimes or the workflow can create a workitem before the Wait step and hang in there till its processed..(its unpredictable which one will trigger first)
    If the second event(for Wait step) is raised first and the workflow processing has not yet reached the Wait step, the workflow waits for the event to be raised(although the event is already there)
    Do you know of some way we can keep reprocessing until the Event receiver is found? (may be in a Raise event workflow step or in a Function Module)
    Edited by: sk123456 on Jun 5, 2010 11:47 AM

  • How to listen one event before another

    Hello All,
    In my code i m using 2 Events (selectionEvent , FocusEvent) at one object(Gallery). when i select any object in gallery , focus event comes first before Selection Event. but i want selection event shud come before Focusevent. so that i may perform some operations in widgetSelected(SelectionEvent e){...} before the method focusGained(FocusEvent e){....}
    please suggest me in this direction.

    We'll stay in this one: [http://forums.sun.com/thread.jspa?threadID=5345923]

  • How to listen one event before another event

    Hello All,
    In my code i m using 2 Events (selectionEvent , FocusEvent) at one object(Gallery). when i select any object in gallery , focus event comes first before Selection Event. but i want selection event shud come before Focusevent. so that i may perform some operations in widgetSelected(SelectionEvent e){...} before the method focusGained(FocusEvent e){....}
    please suggest me in this direction.

    You should, however, be able to write your focusGained method in such a way, that it does different things according to the selection state of your widget and your widgetSelected method in such a way, that it does different things according to the focus state of your widget.

Maybe you are looking for

  • Itunes 11 appears to download my CD but it does not show up in my music?

    I insert my own CD. itunes goes through the importing process on each track, but when it is done, the new tracks do not show up in Music or Recently added.  Where is it?  I do not have itunes Match.  Any ideas?  I import my own CD's like this all the

  • Error message opening secure PDF file

    I bought a secure water marked PDF file and am unable to open it on my computer.  I get an error message saying, " There was an error processing a page.  Wrong operand type."  I'm able to download the file and open it on my Android cell phone, but if

  • Photoshop CS5 - Completely unusable.. help!

    OK.. where do I start... My company recently purchased a licence for Photoshop CS5 (Mac) at my request, and I am now stuck in the unenviable position of telling them it was a complete waste of money.  Hopefully someone can help me resolve some of the

  • Sending mail on error

    Hi, Is it possible for EM to send a mail when some oracle errors occure EM 10gR4

  • Need Help setting up microphone, Using Soundblaster AUD

    Hey everyone, i jsut wanted to say , im having troubles with setting up my microphone, i have the latest Audigy ZS drivers installed and have the microphne connected to the right jack, but cant get any sound , can anyone help me or has anyone else ha