Release resource

Hi
I think it is a good practice to release resource (eg, db connection) whenever the user session is ended or time-out.
I do the following things:
class myHttpSerlvet extends HttpServlet implements HttpSessionBindingListener
then all the servlets in my application extend from myHttpServlet.
Then i can release resource in the valueUnbound operation of the servlets.
Am I right? Is there any performance consideration?
Thank you
Leo

Well, this really isn't necessary. The various JDBC classes all implement finalize() to release their resources. So, when the session is destroyed, those objects will be garbage collected and the resources will automatically be removed.
A better plan would be to not have the database connections in the session at all. Instead, use DB connection pooling. For example, javax.sql.PooledConnection. Then you can just keep reusing the same connections and don't have to deal with constantly connecting and disconnecting, and you have better load management on your database.

Similar Messages

  • Weblogic 9.2 - Problem with Connection Pool not releasing resources

    We have a third party application that is running Weblogic 9.2 and has a connection pool to a SQL 2005 db for queries within it's batch process. What I have noticed is that it does not seem to be releasing SQL cpu back after the batch and this is causing issues with processes for other dB's within the instance. Has anyone encountered this issue and if so what is the solution (short of isolating it within it's own instance). Can the connection be reset to release resources?

    Yes it is a weblogic connection pool. What I mean is that when a batch run I can see the CPU for the SQL process associated with the connection increase but when the batch is completed the CPU remains high when I would expect it to move back down to an 'idle' level as after that as all it would be doing is the occasional "select 1' ping to keep the connection active.
    What i do see is that the cpu in activity monitor shows high cpu and it never goes down unless the connection is killed and re-established. As this is a shared instance other apps are complaining of slow running procs.

  • When I close CAcroPDDoc, Why acrobat.exe NOT release resource?

    Hi everybody.
    I use CAcroPDDoc to open many PDFs, and read its page number.
    Everytime I got the page number, I was close the CAcroPDDoc.
    But acrobat.exe did not release resource. At last error happened!
    What can I do?
    CODE:
    long CWorker::GetPagenum(CString strPDF)
    long lNum;
    CAcroPDDoc *pPDdoc=new CAcroPDDoc;
    pPDdoc->CreateDispatch("AcroExch.PDDoc");
    pPDdoc->Open((_bstr_t)strPDF);
    lNum=pPDdoc->GetNumPages();
    pPDdoc->Close();
    delete pPDdoc;
    return lNum;

    Acrobat will release the document usually about 30 seconds after you ask it to...

  • How do I use resource or release resource based on boolean?

    I have a case where I need to turn a AO on and off and when turned off I need it set back to zero offset. I need to do this with four different AO channels each with their own boolean switch. I have it setup but what I am having trouble is releasing the resource after the first switch is turned on then off.
    The logic seems to escape me.

    Hi THurst,
    I will like to step into the forum and suggest a more simple approach, if you can run this shipped example: “Cont Gen Voltage Wfm-Int Clk-Non Regeneration.vi”, and simply write a waveform with amplitude zero, before ending the task.  This might be a good resource to look at: What is the Difference Between the DAQmx Stop Task.vi and DAQmx Clear Task.vi? , The screenshot might give you an idea, but basically you press the Boolean to change the amplitude of the sine wave to zero and then you stop the task.
    I hope it helps
    Message Edited by Jaime F on 12-12-2007 02:48 PM
    Jaime Hoffiz
    National Instruments
    Product Expert
    Digital Multimeters and LCR Meters
    Attachments:
    zero offset.png ‏22 KB

  • Release Resource from Project during closeout?

    Hi,
    How to release a resource from Project during project closeout. I found the following options, please suggest the procedure,
    Case : 1. Created Requirement
    2. Assigned Resource (Provisional)
    3. Submit for Approval
    4. Approver approves assignment.
    Option A:
    1: Update Requirement duration
    2. Enter new End date
    3. Subimit for Approval
    4. Approver - Approves assignment
    Option B:
    1. Cancel resource requirement
    Is there any way to release the resources from project. This should reduce the resource available hours ?
    Regards,
    AK

    Hi,
    I also strongly recommend you to read the following material. It is long, I know, but covers almost everything, including your questions:
    Working with the Development Infrastructure
    http://help.sap.com/saphelp_nw04s/helpdata/en/03/f6bc3d42f46c33e10000000a11405a/frameset.htm
    This includes also some conceptual descriptions, tutorials, it describes among others the component model, and nwdi elements one by one like cms, dtr and cbs, etc, I believe it is a good start.
    Still, let me briefly, but really only in a nutshell answer your questions.
    The changes are only in inactive after checkin. You won't find in active, only if you activate (for details about actvation please refer to the above guide, since if I go into details, I am afraid the answer will be too long).
    This was so far the dev/inactive and the dev/active part.
    Then you release the changes and import into consolidation. Here it is indeed tricky, since a force activation takes place after a succesful import, so your changes will be visible in both cons/inactive and cons/active.
    You also asked what to consider if you delete a DC:
    #864515 - How To Delete a Development Component
    You wanted to know where to monitor activities. For this go to the CBS webui and check the "Activities" page.
    Here you can look up all the activations took place in the past,  you can check pending activations, etc, you can even use CBS webui to activate.
    Release: You are completely right, there is no release feature in any webuis, as this feature was never implemented. While you can activate from NWDS and from the CBS webui, regarding release the only option is NWDS.
    I hope this helps, let me know if you require more clarification.
    Best Regars,
    Ervin

  • Whcih function to use to cleanup/release resources before application exit?

    I need to release system resources and cleanup etc before my JavaFX application exits?
    Where should I write the code?

    In [javafx.lang.FX|http://java.sun.com/javafx/1.2/docs/api/javafx.lang/javafx.lang.FX.html] class, there is the static function addShutdownAction() which is called when the application exits.
    You can register several functions.
    But some people report issues, like being unable to do an HTTP request to save parameters on server in these callback functions (the application exists before completion).

  • Releasing Resource (File Handle) and Document Builder

    I am currently working on a project that uses a Jar file containing XML configuration files. The Jar file needs to read this file and the DocumentBuilder.parse method is called on the XML files. Later, new XML files need to be added to this same Jar file.
    The problem is that at that point I can't open the Jar file for writing because I can't unlock the file since it is held by the DocumentBuilder. Even when these objects go out of scope and are deleted the resource is not being unlocked. The only solution I've found is to copy the file and read from the copy and write to the original. This solution leaves extra files lying around though and is not very elegant. Is there anyway I can force that file handle to be destroyed and unlock the configuration file resource?

    That could be.....
    Basically I create a URI object using the path for the Jar file and the XML file within it. Then I use URI.toString() and give that to the Document Builder.
    DocumentBuilder.parse( StringURI )

  • Force outputstream to release resources?

    im running my program from a jar file.
    just for fun i create a FileOutputStream to that same jar file then close it. i dont write anything.
    then when i try to instantiate a class from that jar i get a class not found error.
    if no one can tell me why, can someone tell me where i can learn more about OutputStreams?

    When you open a FileOuptStream and don't specify 'true' as a second argument in the constructor, it delete the existing file and then create a new empty one. As you can guess the second arguement is an append option.

  • Web browser resource use in kde4

    My testing was not extensive.  I opened 2 tabs in each of 4 browsers and only looked at cpu use after about a minute.  One tab was used for gmail and the other for hulu.  These should test what most people want to do.  I also went to random other sites to see what happened.
    Chromium 13, Firefox 6, Opera 11.5, and Konqueror(using kde 4.7 and KHTML) were used. 
    None of the browsers had a problem with watching flash videos on hulu with Konqueror having the best transition to/from fullscreen flash and opera 2nd best.  Firefox was good and Chromium not so good.  Konqueror would use the most resources when starting a flash video, likely due to the flashplugin requiring a wrapper.
    Gmail was best on Chromium.  Konqueror would only show the basic view and would not render in standard view.
    In general, konqueror used the least resources except when loading and was quickest to release them.  The others all used about the same resources with Opera releasing them quicker.  Chromium would use fewer resources to start but would be reluctant to release them.  Firefox was good but not great.  None crashed or slowed the system significantly.
    Konqueror was slowest on sites with flash and fastest on sites without, using the least resources(on average) in a kde environment but having issues rendering some sites.  Chromium is slow to release resources and I would not use it on constrained systems but was quite fast.  Opera was good for resource use and speed.  Firefox was slowest but not by much and is very good for random websites.

    Oh, I posted this to the Macbook forum as it's ambiguous whether the update caused a hardware/software confliction, since a fresh install of Snow Leopard did not work.

  • Apple has reportedly delayed the release of iOS 5.0.2

    Apple has reportedly delayed the release of iOS 5.0.2, German-language technology blog Macerkopf.de said on Monday. Rumors surfaced last week suggesting that Apple was preparing to release the update, which is expected to address poor battery life with iOS 5, out of the door before the end of this week. Macerkopf.de said iOS 5.0.2 has been delayed to fix “address-based memory leaks,” or bugs that cause apps to consume memory without releasing resources once they are no longer needed. A new release date for iOS 5.0.2 has reportedly not yet been scheduled.

    I saw  it when i searching the web again today Apple has reportedly delayed the release of iOS 5.0.2

  • Publishing service - "Released" status not visible

    Hi All,
    Users cannot see my KM documents "released" by the publishing service. I am creating content using a standard SAP form within a folder set up for publishing.
    I have turned on the publishing service on for a repository, and for a folder "announcements" I have enabled approvals, and set up the process, however I am having an issue where I cannot see "Released" status documents for my end users. 
    The security looks ok. I have set up a read permission for the "Everyone" group on the repository root. This has propogated to the "Released" resource. To be sure, I even added a read permission to a resource (Released) for a test user, but they cannot see it!
    Any ideas?

    Thanks guys - super quick answer.  The "publish from" date and "publish to" dates were exactly the same, HOWEVER, once I changed the dates it took at least 15 minutes to see the changes, as such I assume a batch service is responsible for the delay.
    Many thanks - I beleive I have awarded points to both of you.
    And... Merry Christmas - much appreciated.

  • Child Process resource cleanup

    the problem I am having in my application is that resources are "leaking" (but not really) because memory is not used a lot (all the work is done by child processes) but since Process class does not have any means to explicitly release system resources taken by .exec, I ended up having a bug (.exec would fail after a while). Only after adding rtm.gc() the application worked as expected.
    I have code something like this:
    final Runtime rtm = Runtime.getRuntime();
    try {
    Thread.sleep(5000);
    for (int i = 0; i != 100; ++i) {
    Process prc = rtm.exec(new String[] {
              "cmd.exe", "/C","\"echo hello\""                     });
    Thread.sleep(1000);
    prc.waitFor();
    rtm.gc(); // without this, it will NOT release resources
    System.out.println("finished");
    Thread.sleep(20000);
    } catch (Exception e) { 
    qeustion is: is there not a way to release child process' resources without having to call garbage collection?

    My child process does terminates correctly.
    It looks like Process object is not freeing up resources it holds for the process (input/output/err streams and process handle itself). Since gc does not kick in (there is almost no memory consumption), it takes a long time until it's cleaned up (if ever)
    Adding:
    prc.getOutputStream().flush();
    prc.getOutputStream().close();
    prc.getInputStream().close();
    prc.getErrorStream().close();
    after
    prc.waitFor();
    changes things a bit, it reduces number of handles process still holds (after the child process has finished execution) to 1. There is still, however, one handle held by the Process object, my guess is - process handle.
    It is a pitty there is no way to "tell" process object to release this one last handle. Or maybe there is?

  • Jasper Reports Integration - beta release

    Hi guys,
    I have finally found the time to release the Jasper Reports Integration package for producing print ready reports.
    You can find all the details here: http://daust.blogspot.com/2010/01/jasper-reports-integration-beta-release.html
    Anybody is welcome to try the software and join the beta program.
    Thanks,
    ~Dietmar.

    Hi Wolfgang,
    Now it works as expected!That's the way I like it ;).
    I would like to save the report in a user table with a blob field, how can this be achieved?Easy, this is even already part of the test application.
    On the Report Tester tab you will find a button called "Get report as BLOB, then display". It calls the following page process:
    DECLARE
       l_blob        BLOB;
       l_mime_type   VARCHAR2 (100);
    BEGIN
       xlog ('PRC_GET_REPORT_TUNNEL', 'url (orig):' || :p5_report_url);
       -- generate the report and return in BLOB
       xlib_jasperreports.set_report_url (:p5_jasper_report_url);
       xlib_jasperreports.get_report
                                    (p_rep_name               => :p5_rep_name,
                                     p_rep_format             => :p5_rep_format,
                                     p_data_source            => :p5_data_source,
                                     p_rep_locale             => :p5_rep_locale,
                                     p_rep_encoding           => :p5_rep_encoding,
                                     p_additional_params      => :p5_additional_params,
                                     p_out_blob               => l_blob,
                                     p_out_mime_type          => l_mime_type
       -- set mime header
       OWA_UTIL.mime_header (ccontent_type      => l_mime_type,
                             bclose_header      => FALSE);
       -- set content length
       HTP.p ('Content-length: ' || DBMS_LOB.getlength (l_blob));
       OWA_UTIL.http_header_close;
       -- download the file and display in browser
       WPG_DOCLOAD.download_file (l_blob);
       -- release resources
       DBMS_LOB.freetemporary (l_blob);
       -- stop rendering of APEX page
       apex_application.g_unrecoverable_error := TRUE;
    EXCEPTION
       WHEN OTHERS
       THEN
          xlog ('PRC_GET_REPORT_TUNNEL', SQLERRM, 'ERROR');
          RAISE;
    END;Once you have the blob you can store it in a database table, done!
    There is only one tricky part. Should the Tomcat throw an exception then it will return a html error page (http code 200=ok). The request is perfectly valid but a human can see the error message.
    The API should throw an exception on that. A bit tricky once other J2EE servers are supported or the error messages vary.
    BTW: do you plan any additional features ?Perhaps, what are you looking for?
    Cheers,
    ~Dietmar.

  • IDCS5 Mac - release plugin not loading

    I have several "release version" plugins that are not loading on my CS5 Mac machine.
    The Porting Guide says that if the folder is inconsistently named with the plugin or if a resource file is missing, the plugin will not load.
    I carefully checked the package and the folder is named the same as the app file (with the exception that the folder also has ".InDesignPlugin" added to its name--I am assuming that variation is acceptable).
    I checked the folders and the files in the folders between the debug version and the release version.  With one exception the release resource folder mirrors the debug resource folder.  That difference is in the presence of a single file: timestamp.
    Where does it come from and how can I get my release version project to generate one?
    Are there other possibilities I should look into?
    TIA!
    R,
    John

    Dirk:
       You correctly guessed the problem.  Actually, what was happening was that I was using MySQL in both plugins.  Because I was developing on my computer, I of course had the MySQL libraries loaded, but the production computers had the wrong libraries installed. With the help of a colleague (Dan Morris deserves this credit) the above fact was discovered.  I dropped back a couple of versions in the libraries I was using, recompiled, and the problem was resolved.
       Take care,
    John

  • Howto free resources when servlet reaches timeout?

    Hi there!
    I have written a small servlet which is mainly used to communicate via different types of clients using http.
    SoI only use the servlet as a "http-receiver", behind there works a complex buissnes logic withought any servlet/jsp/j2ee-stuff.
    I know these are basic questions but till now I did not find any answer to the following questions:
    1.) How can I change the session-timout?
    2.) How can I release resources (db-connections, ....) after session timeout exceeded?
    Maybe you know a servlet-tutorial which covers questions like the quests above, such a tut would help a lot ;-)
    Thanks a lot, lg Clemens

    1) you can set the session timout either in code with session.setMaxInactiveInterval(), or in the web.xml with the <session-timeout> element.
    2) The HttpSessionBindingListener interface has a method called valueUnbound() that gets called when the session expires. You can use that method to release resources. Define a timeout notifier class implementing the HttpSessionBindingListener interface. Create an object of that new class and add it to the session. When the session times out, your notifier's valueUnbound() will be called .
    Don't forget to add you notifier class in the listener tag of the web.xml :
    <listener>
      <listener-class>package.notifierClass</listener-class>
    </listener>As for some doc, this one should do it.

Maybe you are looking for

  • Accounting document not created for the  billing document in CIN

    Hi Experts, I have made conditon records for BED, CESS, Edu Cess and VAT. I hve defined the accounts in both excise transactions and VKOA Settings even then the accounting document is not getting created. I am getting the following error. No account

  • Save system settings to project file?

    I've been working on quite a few projects on different hard drives simultaneously as of late. I just wondered if there is any way to save my Final Cut system settings to the .fcp project file; it's getting annoying to reset the scratch disks every ti

  • In purchase history, there're 2 Subscription pendi...

    In purchase history, there are 2 subscription pending, 2 are created. It might be by mistake when I trying to charge Skype credit. It's all for the same product, is it necessary to cancel them? If yes, how can I actually cancel them? Thanks in advanc

  • I am having trouble with disk space,

    I am having trouble with disk space, I am always getting the error message that I need to delete files on my start up disk, I am all out of space. I cant even save a file to my desktop without getting the message, Is there a way I can free up space.

  • Library module issues

    I've lost "Catalog and Folders" in the Lightroom 4's Library Module.  How do I get them back??