Release of resources

In case of message receive program(daemon kind of ), when do I release the resources? Memory is getting blocked. It keeps on waiting for an incoming message.
Any suggestions plz
thanks
shiva.

If you are more clear in your problem maybe i will be able to help you..
Well after sending a message u can send a null message and check for the same on the receiver application..then release the resources for the same..
Hope this helps you.

Similar Messages

  • Images - are there frame buffer copies? How to release those resources?

    Hello,
    I'm a bit confused about the memory usage of images (BufferedImage class) in a Swing application.
    I have about 50 Buttons (my own class derived from JButton), which use some images to render themselves. The images are cached, of course - although there are 50 button instances, they all use the same set of image instances.
    Theses images instances use not more than about 2 mb of heap space (uncompressed images). But when I look at the heap usage via a memory profiler, the memory usage of those buttons is much more than 2 MB.
    Now, I'm not a swing expert knowing about all internal structures, so I can't imagine why the buttons instances use a lot more memory than the sum of those image instances (I mean a lot more, not only the memory overhead that comes with the button instances), so maybe you can help me. Is there anything like a frame or drawing buffer, where those images data is copied to and internally used for rendering? I could imagine, that it is much more faster to draw from the graphics card memory than from the normal heap memory, is this correct? Maybe this is the answer, why the memory usage is much higher than those 2 MB?
    Additionally, is there anything I have to know about releasing image resources, is there something special? Or is the GC able to free those BufferedImages (and perhaps connected frame buffer copies?) as usual?
    I really appreciate your help
    Thanks a lot

    The profiler specifically said there were x+ instances of BufferedImages and that they were using more then 2MB?

  • Releasing hardware resources on LabVIEW crash

    Hi all,
    I am using PXI chassis with many DAQ cards, mux, ARINC,RS-422 etc.
    It is a common problem that in the event of LabVIEW crash, the hardware resources are not released and the system should be restarted to access the resources again.
    Scenario:
    LV1 is the main LabVIEW program that opens the harware resources. 
    LV2 is a separate LabVIEW program (a utility) runs as a separate process.
    Now if the LV1 opened few references to the hardware devices and shares these references to the LV2.
    In the event of LV1 process crash, LV2 still runs; can the LV2 process close the open references?
    Can LV2 process release the resources opened by LV1? 

    It really depends a little. Even XP was fairly good about releasing normal OS objects such as all kind of handles (files, synchronizationo objects, GDI objects, etc). But once kernel resources get involved things get a lot  more trickier and I really doubt there is an universal way for an OS to make sure even such resources get properly closed on process termination without a very intensive, expensive and performance hungry bookkeeping. And I don't see the average user wanting to pay that price in performance all the time for the incidential case when the system crashes.
    So in general it is safer to restart the OS after a crash even if the system seems to work fine, This is definitely true if your application has been involved in some way with directly invoking kernel drivers, which any application that interfaces to NI (and other manufacturers) hardware basically does. I'm not saying that NI couldn't possibly improve that in the user space part of those drivers somehow. However the effort for that could be pretty expensive and the perceived advantage would be small for most end users.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Releasing File resources after "new File()"

    Hi, I'm experiencing the following problem. I'd like to list the properties of files in a directory, so I do something like
    File dir = new File(".");
    String[] files = dir.list();
    for(int i = 0; i < files.length; i++){
    System.out.println(new File(files).lastModified());
    I gather these calls to "new File()" do hold some read locks to the files, when are these locks released? at GC time? is there anyway to force/guarantee the release?

    I gather these calls to "new File()" do hold some
    read locks to the files, No, they don't. File just has metada about the file--name, path, size, etc. It doesn't open the file or lock it or anything.
    The ones you need to clean up are the Input/OutputStreams and Readers and Writers. Those have close() methods. There's also java.nio.channels.FileLock and associated classes mentioned in its docs.

  • Applet within browser not releasing file resource

    hi,
    I have an applet for ftp images upload.
    run from eclipse IDE (which uses applet viewer) the applet is ok.
    if i run my applet from browser here is what happens:
    i upload a file .& leave the browser opened.
    i then open this same file with gimp or photo-shop & get file in use error.
    if i close browser & try opening file .it works ok.
    why the file isn't released when applet instance still on browser ?
    is there a fix to this issue ?
    thanks for helping .

    thanks for prompt reply.
    yes i close all streams...
    the core method i use to upload files is below (client is a FTPClient object)
    private synchronized void putFile(File file, String remoteFile)
                   throws FileUploadException {
              String sFile = null;
              try {
                   sFile = r.chomp(remoteFile, '/');
                   client.put(file.getAbsolutePath(), sFile + file.getName());
                   r.numBytes += file.length();
              } catch (Exception e) {
                   //e.printStackTrace();
                   try {
                        retry(file, sFile);
                   } catch (Exception e1) {
                        throw new FileUploadException(e1.getMessage());
         }what am i doing wrong ?

  • 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.

  • 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).

  • Leopard Resources Management issue

    I have using Leopard for about a month, I don't know if any other user has same issue with me, here is my problem with my Leopard:
    - first time boot, my system has over than 1.5GB free memory
    - I opened an application such as NetBeans, XCODE, ADOBE photoshop, and it runs well, my free memory about 100MB,
    - After I close those apps, free memory doesn't change still on 100MB even drop, and what do I got, open dashboard, switching space is lagging and opening firefox took over than 8seconds or even my system got crashed during quicklook a movie or big pdf.
    Many application will crashed and system runs slower than before I open and close big application, my application all Intel Native, so nothing wrong with the applications...
    The problem is, I think Leopard got big problem on handling resources, specially when an application released their resources, Leopard can't reserved it to another application or system. This should be memory leak issue...cmiiw
    Please give me an advice is there any solution for this or I have to wait till Apple release new update?
    Thanks anyway.

    _Try this as an isolation step:_
    Turn the computer off. Press and hold shift. Turn the computer on. Continue to hold shift until you see the spinning gear below the Apple logo. Once it is started up, log in. Does it do the same thing here?
    Let me know the results for further steps.

  • Oracle Db 10g Release 10.2.0.4.0 - 64bit Production - DB Hang

    Server - IBM AIX
    Database is hanging some times.
    In alert logifles its showing
    ==========================================================================
    $ cat alert_WPCPRODB.log
    Tue Apr 13 09:03:41 2010
    Thread 1 advanced to log sequence 55358 (LGWR switch)
    Current log# 1 seq# 55358 mem# 0: /oratables4/WPCPRODB/redo1/redo01.log
    Tue Apr 13 09:16:20 2010
    kkjcre1p: unable to spawn jobq slave process
    Tue Apr 13 09:16:20 2010
    Errors in file /orahome/oracle/ora10g/admin/WPCPRODB/bdump/wpcprodb_cjq0_761862.trc:
    Tue Apr 13 09:20:03 2010
    kkjcre1p: unable to spawn jobq slave process
    Tue Apr 13 09:20:03 2010
    Errors in file /orahome/oracle/ora10g/admin/WPCPRODB/bdump/wpcprodb_cjq0_761862.trc:
    ==================================================================================
    cat /orahome/oracle/ora10g/admin/WPCPRODB/bdump/wpcprodb_cjq0_761862.trc
    *** 2010-04-13 09:19:39.713
    *** 2010-04-13 09:19:49.715
    Waited for process J000 to initialize for 110 seconds
    *** 2010-04-13 09:19:49.715
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 1.13 1.11 1.45
    swap info: free_mem = 77.24M rsv = 66.00M
    alloc = 2501.88M avail = 16896.00M swap_free = 14394.12M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:19:51.422
    *** 2010-04-13 09:20:01.423
    Waited for process J000 to initialize for 120 seconds
    *** 2010-04-13 09:20:01.424
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 1.09 1.10 1.44
    swap info: free_mem = 76.28M rsv = 66.00M
    alloc = 2501.60M avail = 16896.00M swap_free = 14394.40M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 1 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:20:03.262
    Killing process (ospid 1269840): (reason=x4 error=0)
    ... and the process is still alive after kill!
    =======================================================================
    SQL> show parameter JOB_QUEUE
    NAME TYPE VALUE
    job_queue_processes integer 50
    SQL> show parameter pga_aggregate_target;
    NAME TYPE VALUE
    pga_aggregate_target big integer 2G
    SQL> show parameter pre_page_sga;
    NAME TYPE VALUE
    pre_page_sga boolean FALSE
    After that we can't able to get the sql prompt, its fully hang. Its happened 3 to 4 times in our database. After that we compelled to kill the pmon process for release the resource (after bring down the application & stopping listener). In next startup database comes in normal.
    Can you plz help me why it is happening? Is there any resource locking happening in OS level? How to fix this issue permanently?
    Thanks & Regards
    SIJO JOSE
    BANGALORE
    Mob - 09739394539
    Email Id - [email protected]

    The respective trace file i mentioned here
    Errors in file /orahome/oracle/ora10g/admin/WPCPRODB/bdump/wpcprodb_cjq0_761862.trc
    ===================================================================
    /orahome/oracle/ora10g/admin/WPCPRODB/bdump/wpcprodb_cjq0_761862.trc
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    ORACLE_HOME = /orahome/oracle/ora10g
    System name:     AIX
    Node name:     wpcdb
    Release:     3
    Version:     5
    Machine:     00C6E6FB4C00
    Instance name: WPCPRODB
    Redo thread mounted by this instance: 1
    Oracle process number: 10
    Unix process pid: 761862, image: oracle@wpcdb (CJQ0)
    *** 2010-04-13 09:15:06.219
    *** SERVICE NAME:(SYS$BACKGROUND) 2010-04-13 09:15:06.150
    *** SESSION ID:(547.1) 2010-04-13 09:15:06.142
    Waited for process J000 to initialize for 60 seconds
    *** 2010-04-13 09:15:06.219
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.81 1.46 1.66
    swap info: free_mem = 19.91M rsv = 66.00M
    alloc = 2483.64M avail = 16896.00M swap_free = 14412.36M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 811158 1 0 64 22 25c8e400 86256 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    811158: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001002fe72c kgllkalt(??, ??) + 0x8c
    0x00000001002f4f3c kglssi(??, ??, ??, ??) + 0x5c
    0x000000010013fb80 ksucri(??, ??) + 0x560
    0x0000000100140460 ksucre(??) + 0xc0
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:15:12.766
    *** 2010-04-13 09:15:22.768
    Waited for process J000 to initialize for 70 seconds
    *** 2010-04-13 09:15:22.768
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.70 1.40 1.64
    swap info: free_mem = 4.64M rsv = 66.00M
    alloc = 2490.84M avail = 16896.00M swap_free = 14405.16M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 811158 1 0 64 22 25c8e400 86256 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    811158: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001002fe72c kgllkalt(??, ??) + 0x8c
    0x00000001002f4f3c kglssi(??, ??, ??, ??) + 0x5c
    0x000000010013fb80 ksucri(??, ??) + 0x560
    0x0000000100140460 ksucre(??) + 0xc0
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:15:24.575
    *** 2010-04-13 09:15:34.577
    Waited for process J000 to initialize for 80 seconds
    *** 2010-04-13 09:15:34.577
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.75 1.39 1.63
    swap info: free_mem = 3.96M rsv = 66.00M
    alloc = 2491.60M avail = 16896.00M swap_free = 14404.40M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 811158 1 0 64 22 25c8e400 86256 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    811158: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001002fe72c kgllkalt(??, ??) + 0x8c
    0x00000001002f4f3c kglssi(??, ??, ??, ??) + 0x5c
    0x000000010013fb80 ksucri(??, ??) + 0x560
    0x0000000100140460 ksucre(??) + 0xc0
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:15:36.457
    *** 2010-04-13 09:15:46.459
    Waited for process J000 to initialize for 90 seconds
    *** 2010-04-13 09:15:46.459
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.87 1.39 1.63
    swap info: free_mem = 5.45M rsv = 66.00M
    alloc = 2496.28M avail = 16896.00M swap_free = 14399.72M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 811158 1 1 64 22 25c8e400 86264 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    procstack: write(/proc/811158/ctl): The requested resource is busy.
    811158: ora_j000_WPCPRODB
    0x0000000000000000 ????????() + ??
    *** 2010-04-13 09:15:46.533
    *** 2010-04-13 09:15:56.534
    Waited for process J000 to initialize for 100 seconds
    *** 2010-04-13 09:15:56.534
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.74 1.34 1.61
    swap info: free_mem = 5.11M rsv = 66.00M
    alloc = 2496.11M avail = 16896.00M swap_free = 14399.89M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 T oracle 811158 1 0 64 22 25c8e400 86264 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    811158: ora_j000_WPCPRODB
    0x0000000100087f6c kghfrh_internal(??, ??, ??) + 0x2ac
    0x0000000100094770 kghfrh(??, ??) + 0x10
    0x0000000104272a0c kksFreeHeap(??, ??, ??) + 0xac
    0x0000000104272c38 kksFreeHeapGetMutex(??, ??, ??, ??) + 0x198
    0x0000000101f33868 kksCursorFreeCallBack(??, ??, ??) + 0x88
    0x000000010030ae84 kglobf0(??, ??, ??, ??) + 0x264
    0x00000001002f8cc8 kglhpd_internal(??, ??, ??, ??) + 0x228
    0x00000001002fc850 kglhpd(??, ??, ??) + 0x10
    0x00000001000864e8 kghfrx(??, ??, ??) + 0x28
    0x0000000100084b64 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0xb44
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x0000000100005908 ksp_param_handle_alloc(??) + 0x168
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:15:58.411
    *** 2010-04-13 09:16:08.413
    Waited for process J000 to initialize for 110 seconds
    *** 2010-04-13 09:16:08.413
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.77 1.33 1.60
    swap info: free_mem = 3.84M rsv = 66.00M
    alloc = 2497.99M avail = 16896.00M swap_free = 14398.01M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 811158 1 1 64 22 25c8e400 86264 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    procstack: write(/proc/811158/ctl): The requested resource is busy.
    811158: ora_j000_WPCPRODB
    0x0000000000000000 ????????() + ??
    *** 2010-04-13 09:16:08.485
    *** 2010-04-13 09:16:18.487
    Waited for process J000 to initialize for 120 seconds
    *** 2010-04-13 09:16:18.487
    Dumping diagnostic information for J000:
    OS pid = 811158
    loadavg : 0.73 1.30 1.59
    swap info: free_mem = 3.86M rsv = 66.00M
    alloc = 2497.12M avail = 16896.00M swap_free = 14398.88M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 T oracle 811158 1 0 64 22 25c8e400 86264 09:14:06 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    811158: ora_j000_WPCPRODB
    0x0000000100082084 kghfrmrg(??, ??, ??, ??, ??) + 0x124
    0x0000000100095d5c kghfre(??, ??, ??, ??, ??) + 0x57c
    0x00000001000881e8 kghfrh_internal(??, ??, ??) + 0x528
    0x0000000100094770 kghfrh(??, ??) + 0x10
    0x0000000104272a0c kksFreeHeap(??, ??, ??) + 0xac
    0x0000000104272c38 kksFreeHeapGetMutex(??, ??, ??, ??) + 0x198
    0x0000000101f33868 kksCursorFreeCallBack(??, ??, ??) + 0x88
    0x000000010030ae84 kglobf0(??, ??, ??, ??) + 0x264
    0x00000001002f8cc8 kglhpd_internal(??, ??, ??, ??) + 0x228
    0x00000001002fc850 kglhpd(??, ??, ??) + 0x10
    0x00000001000864e8 kghfrx(??, ??, ??) + 0x28
    0x0000000100084b64 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0xb44
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x0000000100005908 ksp_param_handle_alloc(??) + 0x168
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:16:20.715
    Killing process (ospid 811158): (reason=x4 error=0)
    ... and the process is still alive after kill!
    *** 2010-04-13 09:18:50.793
    Waited for process J000 to initialize for 60 seconds
    *** 2010-04-13 09:18:50.793
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 0.66 1.06 1.45
    swap info: free_mem = 34.36M rsv = 66.00M
    alloc = 2501.22M avail = 16896.00M swap_free = 14394.78M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:18:52.492
    *** 2010-04-13 09:19:02.493
    Waited for process J000 to initialize for 70 seconds
    *** 2010-04-13 09:19:02.493
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 0.64 1.04 1.44
    swap info: free_mem = 20.38M rsv = 66.00M
    alloc = 2499.66M avail = 16896.00M swap_free = 14396.34M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:19:04.244
    *** 2010-04-13 09:19:14.246
    Waited for process J000 to initialize for 80 seconds
    *** 2010-04-13 09:19:14.246
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 0.70 1.04 1.43
    swap info: free_mem = 47.15M rsv = 66.00M
    alloc = 2500.55M avail = 16896.00M swap_free = 14395.45M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:19:15.938
    *** 2010-04-13 09:19:25.939
    Waited for process J000 to initialize for 90 seconds
    *** 2010-04-13 09:19:25.939
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 0.83 1.05 1.43
    swap info: free_mem = 46.87M rsv = 66.00M
    alloc = 2500.50M avail = 16896.00M swap_free = 14395.50M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:19:27.678
    *** 2010-04-13 09:19:37.682
    Waited for process J000 to initialize for 100 seconds
    *** 2010-04-13 09:19:37.682
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 1.08 1.10 1.44
    swap info: free_mem = 10.67M rsv = 66.00M
    alloc = 2500.29M avail = 16896.00M swap_free = 14395.71M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:19:39.713
    *** 2010-04-13 09:19:49.715
    Waited for process J000 to initialize for 110 seconds
    *** 2010-04-13 09:19:49.715
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 1.13 1.11 1.45
    swap info: free_mem = 77.24M rsv = 66.00M
    alloc = 2501.88M avail = 16896.00M swap_free = 14394.12M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 0 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:19:51.422
    *** 2010-04-13 09:20:01.423
    Waited for process J000 to initialize for 120 seconds
    *** 2010-04-13 09:20:01.424
    Dumping diagnostic information for J000:
    OS pid = 1269840
    loadavg : 1.09 1.10 1.44
    swap info: free_mem = 76.28M rsv = 66.00M
    alloc = 2501.60M avail = 16896.00M swap_free = 14394.40M
    F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
    240001 A oracle 1269840 1 1 64 22 25c8e400 86264 09:17:50 - 0:00 ora_j000_WPCPRODB
    open: The file access permissions do not allow the specified action.
    1269840: ora_j000_WPCPRODB
    0x00000001000fc858 sskgpwwait(??, ??, ??, ??, ??) + 0x38
    0x00000001000f9e3c skgpwwait(??, ??, ??, ??, ??) + 0xbc
    0x000000010011db6c kslges(??, ??, ??, ??, ??) + 0x54c
    0x000000010012199c kslgetl(??, ??, ??, ??) + 0x33c
    0x0000000104497958 ksfglt(??, ??, ??, ??, ??) + 0x198
    0x00000001000847b4 kghfrunp(??, ??, ??, ??, ??, ??, ??) + 0x794
    0x000000010007a488 kghfnd(??, ??, ??, ??, ??, ??) + 0x7e8
    0x0000000100098444 kghalo(??, ??, ??, ??, ??, ??, ??, ??) + 0xa24
    0x00000001000058a0 ksp_param_handle_alloc(??) + 0x100
    0x000000010001d21c kspcrec(??) + 0x1bc
    0x00000001001407a8 ksucre(??) + 0x408
    0x0000000103031770 kkjrdp() + 0x350
    0x0000000103dba990 opirip(??, ??, ??) + 0x4f0
    0x0000000102d4a258 opidrv(??, ??, ??) + 0x458
    0x00000001032f05b0 sou2o(??, ??, ??, ??) + 0x90
    0x0000000100000870 opimai_real(??, ??) + 0x150
    0x00000001000006d8 main(??, ??) + 0x98
    0x0000000100000368 __start() + 0x98
    *** 2010-04-13 09:20:03.262
    Killing process (ospid 1269840): (reason=x4 error=0)
    ... and the process is still alive after kill!

  • WLS 8.1SP2 and "already released" warning

    We have tests where our EIS is down and the connection is denied, the RA
              sends a CONNECTION_ERROR_OCCURRED event, which causes the MC.destroy() call
              as it is supposed to, but we always see the following type of message:
              [java] <Apr 22, 2004 5:57:47 PM GMT-07:00> <Warning> <Connector>
              <BEA-190098> <Trying to release a resource that has already been released
              for HooXG8 Line NoTxn Adapter_eis/generic-full-lineJNDINAME.>
              This is a different behavior than our experiences on WLS6 or WLS7 and isn't
              correct. Any ideas why this is occurring?
              Eric
              

    We have tests where our EIS is down and the connection is denied, the RA
              sends a CONNECTION_ERROR_OCCURRED event, which causes the MC.destroy() call
              as it is supposed to, but we always see the following type of message:
              [java] <Apr 22, 2004 5:57:47 PM GMT-07:00> <Warning> <Connector>
              <BEA-190098> <Trying to release a resource that has already been released
              for HooXG8 Line NoTxn Adapter_eis/generic-full-lineJNDINAME.>
              This is a different behavior than our experiences on WLS6 or WLS7 and isn't
              correct. Any ideas why this is occurring?
              Eric
              

  • 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?

  • What is meant by a resource leak ?

    What is meant by a resource leak ?

    Garbage collection manages only memory, not other system resources. If your Java program has plenty of free memory, garbage collection will not be triggered automatically. Usually, however, there are other resources that are more limited than memory. For example, all OSes have limits on the number of sockets, file handles, etc. that can be open. Sometimes this limit is quite low. This is true even on a desktop, e.g. if your system has 128KB of memory, your Java program can easily allocate all the available file handles without coming near to filling up the heap. If this happens, your Java program will fail. This is what we call a resource leak; the unintentional maintenence of references to non-memory resources.
    This is why it is important in Java to explicitly manage non-memory resources. Classes which utilize non-memory resources should provide ways to explicitly allocate/deallocate those resources, independent of garbage collection. For example Socket, InputStream and OutputStream each provide explicit close() methods for deallocation of file descriptors, Window provides a dispose() method to free the window handle, etc. The way to properly use these classes is to allocate using the constructor, then deallocate using the appropriate method (deallocation is preferably done in a finally{} block, so it will execute whether or not an exception is thrown during use). These classes do release these non-memory resources in their finalize() method, but remember that the finalizer only gets called by the garbage collector, and if the object is never collected, it will never be finalized, hence will never release the resources.

  • Timer won't release - What am I doing wrong?

    Hi,
    I am farely new to C#, but not new to programming.  I try to develop a class that need a timer to update a file.  The problem I have is that when the class is release (like a local variable is destroyed when we exit the method), the timer
    is still in function updating the file.  Here is a sample class I wrote that will show you what is happening:
    First, let me tell you that I tried in VS Community 2013 and in VS 2010 with the same result.
    Here is the class:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Timers;
    namespace TimerDemo
    class MyTimer
    // Var
    private int countVal;
    private string internalId;
    private System.Timers.Timer otimer; // Timer
    // ==================================
    // Property
    // ==================================
    public string Id
    get { return internalId; }
    set { internalId = value; }
    // ==================================
    // Constructor
    // ==================================
    public MyTimer()
    countVal = 0;
    internalId = RandomId(8);
    otimer = new System.Timers.Timer();
    // 2 seconds timer
    otimer.Interval = 2 * 1000;
    otimer.AutoReset = true;
    otimer.Elapsed += new ElapsedEventHandler(timer_Elapsed); // set timer event handler
    otimer.Start();
    // ==================================
    // Timer EVENT
    // ==================================
    private void timer_Elapsed(object sender, ElapsedEventArgs e)
    countVal++;
    // Write to the log
    System.IO.StreamWriter oWriter;
    oWriter = new System.IO.StreamWriter("timerlog.log", true);
    oWriter.WriteLine(DateTime.Now.ToString() + " - Loop # " + countVal + " (Timer #" + internalId + ")");
    oWriter.Close();
    // ==================================
    // Generate random Id
    // ==================================
    private string RandomId(int size)
    StringBuilder builder = new StringBuilder();
    Random random = new Random();
    char ch;
    for (int i = 0; i < size; i++)
    ch = Convert.ToChar(Convert.ToInt32(Math.Floor(10 * random.NextDouble() + 48)));
    builder.Append(ch);
    return builder.ToString();
    // ==================================
    // Destructor
    // ==================================
    ~MyTimer()
    otimer.Stop();
    otimer.Enabled = false;
    otimer.AutoReset = false;
    This class simply creates a timer that will write to a file every 2 seconds.  It will write the date and time, the Internal ID and a counter that will increment with each timer loop.
    Now, add a button to a form with the following code:
    private void button1_Click(object sender, EventArgs e)
    MyTimer lclTimer = new MyTimer();
    MessageBox.Show("Class ID #" + lclTimer.Id);
    This code will create an object from the class then display a message with the class Internal ID.  When you press OK on the messagebox, the button1_click method ends and the local lclTimer object should be released.  BUT the timer is still writing
    to the file.  In fact, it will continue until you end the program.
    If you press the button again, a new object will be created with a new ID.  The new timer will also update the log file.  We are now with 2 timers that updates the file.  You may press again on the button to create additionnal timers...  but
    you will eventually get an error when two timers try to write to the file at the same time.
    Here is what the file will look like with 3 timers for a few seconds:
    2015-02-24 20:41:27 - Loop # 1 (Timer #48263556)
    2015-02-24 20:41:29 - Loop # 2 (Timer #48263556)
    2015-02-24 20:41:31 - Loop # 3 (Timer #48263556)
    2015-02-24 20:41:33 - Loop # 4 (Timer #48263556)
    2015-02-24 20:41:34 - Loop # 1 (Timer #86329571)
    2015-02-24 20:41:35 - Loop # 5 (Timer #48263556)
    2015-02-24 20:41:36 - Loop # 2 (Timer #86329571)
    2015-02-24 20:41:36 - Loop # 1 (Timer #80876526)
    2015-02-24 20:41:37 - Loop # 6 (Timer #48263556)
    2015-02-24 20:41:38 - Loop # 3 (Timer #86329571)
    2015-02-24 20:41:38 - Loop # 2 (Timer #80876526)
    2015-02-24 20:41:39 - Loop # 7 (Timer #48263556)
    2015-02-24 20:41:40 - Loop # 4 (Timer #86329571)
    2015-02-24 20:41:40 - Loop # 3 (Timer #80876526)
    2015-02-24 20:41:41 - Loop # 8 (Timer #48263556)
    So here is my question:  What did I miss?  How can I make sure the timer is destyoyed when the class is released?  It seems that the .Stop() call don't really stop the timer...
    Thanks.

    Unlike their counterparts in c++, destructors in c# don't get called when an object goes out of scope. Instead, they are called when the Garbage Collector decides to clean up that object if it unused. If an object is attached to a Timer that is still
    running, the Garbage Collector will think that it's still in use and won't try to remove it, so the destructor won't be called.
    Generally speaking, destructors in c# are fairly useless.
    I think you will need to add a Stop method to your MyTimer class and call it explicitly in button1_Click before the object goes out of scope.
    I agree with Ante Meridian. However, rather than implementing a Stop() method, it is common convention to implement Dispose(). This function is explicitly called to indicate "I'm finished with this object, so do what you must to release internal resources
    now, rather than waiting for the garbage collector. Moreover, Dispose() is automatically called if it is used inside a
    using statement, as in the following example:
    using (MyTimer timer = new MyTimer)
    timer.Start ();
    // Do stuff here
    timer.Stop ();
    } // timer.Dispose() automatically called when leaving scope

Maybe you are looking for

  • At a total loss how to export IPhone 4 video To My PC

    I've read and posted in various threads and looked all over the net. I admit I'm at a total loss as what I'm doing wrong at this point. I want to take the video from my Iphone and move it to my PC so I can upload it in HD to youtube. I've made sure t

  • Batch Management and shelf life

    Hi, We need to automatic batch creation for some externally procured materials. These material are also have shelf life expiration date. I activated in the material master the batch management, but at the time of goods receipt it is not creating new

  • Is a SSD drive for a new Mac Pro "worth it"?

    I will be purchasing a new Mac Pro quad-core in the next month or so. My computer usage, other than email and some word processing, consists primarily of editing RAW photo files using Nikon Capture NX2, Photoshop Elements, and iPhoto. I do almost not

  • Dragging Channels To Layers Help Needed

    Hi Folks, I've been working with the tutorial link below to get rid of some stains, While I have no problem working directly on the channels, I'm lost as to what it means to drag the channels onto layers. I can't seem to find a reference as to how to

  • BufferedReader cannot resolve symbol

    Hi, I need some help with a java program which reads xml files to a specified location, running it on a UNIX machine using Java 1.4.1. I modified the code to include the BufferedReader class, but it keeps complaining about not being able to resolve s