Garbage collector and JPEG decoder

Hi,
I have a problem with the garbage collector decoding JPEG images received on a TCP socket. The process works but each time that I have to decode an image I have to create a new decoder, this causes that the garbage collector starts to work constantly looking for memory. When the gc starts to work the streamed images almost stop since the gc takes all the process.
Here is the code that has the problem. On this code you can see that I create a new ByteArrayInputStream and a MediaTracker, but I know how reuse this objets, the problem is on the decoder.
Does any one have an idea of how to solve it?
Thanks
public void cargarImagen(Visualizador vision,
                              Cabecera cabImg,
                              boolean completa,
                              boolean grabar,
                              boolean pantCIF,
                              JFrame1 jf1)throws Exception{
        Visualizador aux;
        ByteArrayInputStream byis = new ByteArrayInputStream(s1.buffer);
        try{
                decoder=JPEGCodec.createJPEGDecoder(byis);
                try{
                       // decode
                                               vision.image_Webcam=decoder.decodeAsBufferedImage();
                }catch(ImageFormatException b){
                  System.out.println("Incorrect image format");
                }catch(Exception a){
                  System.out.println("Incorrect image");
                mediaTracker_track = new MediaTracker(vision);
                mediaTracker_track.addImage(vision.image_Webcam, 0);
             mediaTracker_track.waitForID(0,500);
        }finally{
                  byis.close();
        if(mediaTracker_track.statusID(0, false) == MediaTracker.COMPLETE){
              vision.repaint();
         else{    /* incorrect image */
              vision.image_Webcam = null;
              System.out.println("Discarded image");
}

I think that this is not the case. Images come from a TCP connection and the application start to read the next image from the socket when the previous one has been decoded and painted.
So, images are not stored on memory and the received images rate depens on how fast is the application reading images from the socket.
However, it is a good idea to start gc before getting next image, the average rate will decrease but it will avoid the "jumps" on visualization.

Similar Messages

  • Garbage Collector and verbose GC

    Hi, we are getting strange behavior with the garbage collector if the verbosegc is enabled. The gc still report it is collecting memory but none is ever freed. If the option is not enabled the problem disapear. Has anyone experience something similar?
    We are running on Sun 5.8 with weblogic 5.1 sp 8 and jdk 1.2.2_09

    Can you post some of the verbosegc output? Output with -XX:+PrintGCDetails might
    help a little more.

  • Garbage collector and JVM

    is garbage collector is part of JVM or it is part of our program process.
    ie ... if we are having 3 programs running at the same time will we have one garbage collector for them or we will have 1 each ofor each process.
    what is the priority of the garbage collector as a process.

    GC is a part of JVM. GCs from different JVMs never
    intersect.hmm.
    So if i am having 3 programs of java running on one machine. how much JVM will i be running ... i guess one. so will they share one GC ???
    what is the priority of GC at process level???

  • Garbage collector don't works.

    Hello people !
    When I restart the weblogic server this do not shows the lastest change that I made. I think the problem is related to the garbage collector and its bean tree.
    Do you known how to solve this?
    Thank you.
    Regards.

    I'm working with WebLogic Server 10.0 and the problem is if I restart the server this don't holds the lastest change that I made, it happens with any type of change (deploy, undeploy, create or delete servers/services, etc).
    I've reviewed the log file and I've found the following error:
    <Jun 2, 2008 6:45:14 PM CDT> <Warning> <Management> <BEA-141269> <The temporary bean tree updateDeploymentContext(Mon Jun 02 10:46:11 CDT 2008) was allocated for an undo, get, or activate operation, but has not been garbage collected.>
    Stopping PointBase server...
    PointBase server stopped.
    Thank you for your attention

  • Force Garbage Collector calling

    Hello
    I have simple, static, single thread program. But it's a lot of memory demanding (large SortedSet, about one million items). After I finish working with this big SortedSet, I call "clear()" on it, for safe. Function uses this Set exits, and reference to this Set dies. Problem is, when this function exits, it's called multiple times again (same function), but unreferenced memory is still occupied, and heap usage grows and grows.
    I need to force calling Garbage Collector and HALT MAIN PROCESS until GC refreshes all of unref. memory.
    I tried calling "System.gc()" - without effect, parameter "-Xincgc" - without effect.
    Thank you very much for help.
    Pleas excuse my poor English, but I hope you understand me.
    Tony (Czech Republic)

    Why is this growing heap a problem, and why do you feel compelled to force gc?
    Virtually all non-trivial applications experience growing and growing heap usage.
    But the JVM should run gc when it is running out of memory anyway.
    Did you get an OutOfMemoryError?
    If you did, then you should review either your JVM heap settings, or in the worst case, your code. Your program may unintentionnally hold on to objects after being done with them (a java 'memory leak').
    If you didn't get an OutOfMemoryError, then I suggest you don't worry about it.

  • Clear method and Garbage Collector

    Hi Gurus,
    Does the Clear method (hashtable, vector etc..) is a good option for garbage collection ?
    In other words, if I have a vector V with 100 elements and I perform a V.clear(), am I sure that the 100 elements are now candidates for the Garbage Collection ?
    Or is it better to write a loop performing a NULL assignment for each element of the vector ?

    Hi schapel,
    I know it's not a good idea to force the garbage collector, but let me explain what I am confronted with.
    (FYI, I didn't write the source code. Comes from a 3rd party)
    The aim is to build a jsp page which is the list of the files contained in a web server directory.
    I have a "Directory" class, and a "File" class. To build the jsp, each directory of the webserver is represented by a directory class, and each file, ...by a file class.
    To simplify, when the tree structure of the web server is build in memory, I create a jsp page to list the files, and then, I do not need the vector anymore. But the vector can be quite huge and each client will build his own vector at the begening of his session (and will never use it again during the session).
    Don't you think it's usefull in that situation to free some memory ?

  • EMCC and Garbage Collector

    We have 2 CUCM clusters connected via an ICT. We are migrating users from CM8.6 to CM10.5. During the migration we are changing Users AD attributes so that they disappear from CM8. As this marks the user as Inactive in CM8 (and deletes after 24hrs) this prevents the User from logging into CM10 with EMCC.
    Is there a way around this?
    ie force the garbage collector to run immediately and delete the user
    or remove certain fields in CUCM 8 against the user so that they can login using CUCM10 credentials?
    Thanks
    Rich

    I think you can do something clever here. You can convert the inactive user on cucm 8 back to a standard cucm user and then delete them. This way you can control when to remove the user instea dof waiting for garbage collection. You become your own garbage man :)
    You can conver the users back to standard CUCM users using sql query update...Ths is easy to do
     run sql update enduser set status=1 ( this is the general command to make all users standard cucm users..you don't want to run this..)
    Use this command to make specific users active. You need to use the users extension to filter which user gets converted to standard cucm user
    run sql update enduser set status=1 where telephonenumber like ‘2%’
     This command will update users with extension beginning with 2
    or
    run sql update enduser set status=1 where telephonenumber = '2001'
    This will convert user with extension 2001 to a standard cucm user
     To make sure you got all the users you can use the command
    run sql select * from enduser where status=0
     This should return zero entry. If you find any user there then use the update command on those users

  • I have a memory leak, objective-c 2.0, and garbage collector...

    the code i am using is a modification of the code/problem found in "Cocoa with Objective-C", chapter 3.
    i have tried to use the objective-c 2.0 garbage collector methodology, using @property, @synthesize, etc. when i run the code as listed below i get a leaking message.
    [Session started at 2008-02-01 23:33:37 -0500.]
    2008-02-01 23:33:38.070 SongsFoundationTool[28876:10b] * _NSAutoreleaseNoPool(): Object 0x2040 of class NSCFString autoreleased with no pool in place - just leaking
    Stack: (0x96b10178 0x96a3e0f8)
    2008-02-01 23:33:38.075 SongsFoundationTool[28876:10b] Song 1: We Have Exposive
    2008-02-01 23:33:38.076 SongsFoundationTool[28876:10b] * _NSAutoreleaseNoPool(): Object 0x2060 of class NSCFString autoreleased with no pool in place - just leaking
    Stack: (0x96b10178 0x96a3e0f8)
    2008-02-01 23:33:38.078 SongsFoundationTool[28876:10b] Song 2: Loops of Fury
    The Debugger has exited with status 0.
    when i include the commented out section, in the implementation file section, the description method, and use song1 and song2, in main, instead of song1.name and song2.name the program seems to run fine.
    The Debugger has exited with status 0.
    [Session started at 2008-02-01 23:38:24 -0500.]
    2008-02-01 23:38:24.375 SongsFoundationTool[28936:10b] Song 1: We Have Exposive
    2008-02-01 23:38:24.379 SongsFoundationTool[28936:10b] Song 2: Loops of Fury
    The Debugger has exited with status 0.
    please help me understand what's happening here.
    also, why was it necessary to use
    @property(copy, readwrite) NSString *name;
    @property(copy, readwrite) NSString *artist;
    instead of
    @property(readwrite) NSString *name;
    @property(readwrite) NSString *artist;
    thanks everyone, the code is below.
    // ....................... header file ...............
    #import <Cocoa/Cocoa.h>
    @interface Song : NSObject {
    NSString *name;
    NSString *artist;
    @property(copy, readwrite) NSString *name;
    @property(copy, readwrite) NSString *artist;
    @end
    //.................... the implementation file ..................
    #import "Song.h"
    @implementation Song
    @synthesize name;
    @synthesize artist;
    -(NSString *) description
    return [ self name ];
    @end
    //................................ main............................
    #import <Foundation/Foundation.h>
    #import "Song.h"
    int main (int argc, const char * argv[]) {
    Song *song1 = [ [ Song alloc ] init ];
    song1.name= @"We Have Exposive" ;
    [ song1 setArtist: @"The Future Sound Of Londown" ];
    Song *song2 = [ [ Song alloc ] init ];
    [ song2 setName: @"Loops of Fury" ];
    [ song2 setArtist: @"The Chemical Brothers" ];
    // Display Object
    NSLog( @"Song 1: %@", song1.name );
    NSLog( @"Song 2: %@", song2.name );
    // include statements below if -description method is uncommented
    // then comment out the two statements above. no memory leak if the code
    // is used from the statements below and - description is not commented out and
    // the two NSLog statements above are commented out.
    NSLog( @"Song 1: %@", song1 );
    NSLog( @"Song 2: %@", song2 );
    return 0;
    }

    Normally, your main only has a call to NSApplicationMain(). If you aren't doing a traditional MacOS X application, you will still want at least NSApplicationLoad() to get enough of the runtime to avoid those messages.
    I don't know for sure about the syntax of Objective-C 2.0. That stuff is all new. What error message are you getting that indicated that (copy, readwrite) is required? Could you provide a link to the actual example source? I did a quick check and assign and readwrite are the defaults. It is possible that readwrite by itself makes no sense. But I'm just guessing.

  • Swing components and the garbage collector

    How much care does one need to take with swing components, with reference to running out of stack space? I ask because I'm writing a system for an automotive parts company, and the company tends to not reboot the machines very often...
    Anyway... if a JFrame is closed, is it and all its components marked for GCing? Do I need to call the dispose method, or is this part of the default close behaviour? Or is there something else entirely?
    Cheers

    In class that calls for .setVisible(false) of one JFrame u MUST call
    for dispose() method.
    so
    myFrame.setVisible(false)
    myFrame.dispose()
    myFrame = null // to help the garbage collector
    If u have classes that becames from JFrame (or JDialog) u can
    invoke in its constructors:
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
    This makes uncecessary to call for dispose() method explicetly.
    If u do not have this kind of classes u can invoke this method
    after u have create your JFrame
    JFrame myFrame = new JFrame();
    myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
    The most important thing is REMOVE ALL LISETNERS that u have added, so, if u have classes that becames from JFrame u can ovverride
    the dispose method to do that
    eg
    public void dispose()
    super.dispose()
    removeActionListener(.....)
    and so on
    If u do not have this kind of classes u must remove all listeners u have
    added before u invoke the setVisible(false) method.
    Regards

  • CORBA and garbage collector

    Hi,
    I�m writing a server with a method create(), which returns a new object supplying a home banking service for the clients.
    My question is : when a given client has finished with the home banking object, do I need to call the gc, or is there an efficient one with CORBA (a kind of distributed garbage collector) ?
    Thank you in advance

    Maybe you heard about Distributed Garbage Collector (DGC)? Don't rely on this, since IIOP does not support this. Use PortableRemoteObject.unexportObject() to make remote objects that are no longer in use available for garbage collection.
    Bert

  • Garbage Collector Agent

    Hello, I want to know if the Garbage Collector deletes UnFoldered Document. I have created a custom relationship (ThumbnailRelationship) to attache a thumbnail file (a jpeg) to documents. Now, when some one delete a Document, do I have to create a Override to manually delete the ThumbnailRelationship and the Thumbnail document or the Garbage Collector will take care of it ? Where can I get more info on all those Agents running in the background ?
    Thank you
    null

    Hi -
    No, the GarbageCollectionAgent does not delete unfoldered objects. It cleans up references to objects that have been deleted. For example, say a user names testuser1 owns several documents. Then this user gets deleted - who owns the documents? Or more specifcally, what is the value stored in the owner column in the database table? The GarbageCollectionAgent firsts nulls these attributes, and for some attributes (PublicObject.Owner being one of them) it resets the existing objects to reference some other object.
    So, if you want the rightobject of a custom relationship to be automatically deleted when the leftobject is deleted, you'll have to do that via an override on your custom relationship subclass.
    I think the new admin guide has some more detailed information about the out-of-the-box agents.
    hope this helps-
    dave

  • Incremental Garbage Collector is halting my server for MINUTES at a time.

    I have a Java server which services hundreds (currently 300-700 on average, target of 2000+) of simultaneous client connections, with a staggering number of long lived (but not permanent) objects.
    The docs for incremental garbage collection state: "The incremental garbage collector, which is off by default, will eliminate occasional garbage-collection pauses during program execution." This is NOT true in my case. During peak load, the Server halts occasionally (once an hour or more) and entire MINUTES tick by. Average wait time is 2.5 - 3.5 minutes, the highest I have seen is 4 minutes, 10 seconds. This is entirely unnacceptable.
    The server is on Red Hat Linux 6.2, kernel 2.2.14-5.0, with a gig of RAM. My current command line options are
    java -server -Xincgc -Xms256M -Xmx900M
    And I have just added -verbose:gc to help analyze the gc performance. I have read the gc tuning guide at http://java.sun.com/docs/hotspot/gc/index.html but still feel rather clueless about what is the optimum setup for my particular application.
    I will of course start experimenting, but I was hoping to find a "wise old elf" who might give some useful pointers to accelerate the process, seeing as how the Server is already running in a production capacity, time is critical.

    Are you using a Java application server like Tomcat, Dynamo, WebLogic etc. ?
    In that case consider running several server instances on the machine, with the applicationserver's software load balancer. Find the amount of RAM allocated to the heap per serverinstance where garbage collection runs takes a couple of seconds, and don't allocate more than this to each server. Start as many servers as you have available RAM for.
    This is the approach recommended by application server vendors such as BEA http://edocs.bea.com/wls/docs61/perform/JVMTuning.html and ATG.
    A side benefit of this approach is that in case you get more concurrent users than your computer can handle, you already have the setup for spreading the load over several computers.

  • Optimization of the JVM memory - Garbage Collector

    Hi ,
    Just a question about JVM memory management.
    There is memory limitation of memory usage limitation (1.6M) in JVM.
    Is there any possibility to use "Garbage collector" mechanism to optimize the memory usage?
    Or any suggestions for the JVM memory optimization?
    Thanks a lot!!!

    nicolasmichael wrote:
    Hi,
    the "memory limitation" does not have anything to do with garbage collection, but with the address space your operating system provides. On a 32bit operating system, your virtual address space is limited to <= 4 GB, depending on your operating system (for example 1.something GB on Windows and 3.something GB on Solaris). No.
    Windows 32 bit has a 2 GB application space and can be configured to allow a 3GB space.
    The Sun VM does not allow more because of the way that the executable is linked.
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4358809]

  • Single item having content type property set for both GIF and JPEGs

    Is it possible to have a single blob column in the database that stores either jpegs or gif files and then the ability to display either type through a hyperdrill on a Discoverer item? If so, how can the content type property on an blob item be set to two options?
    regards
    Paul P

    Hi,
    Discoverer will use the content_type property to set the MIME type used when opening the blob. So if your blob contains more than one type of file and you want to use different programs to view the files then there are 2 options you can use:
    Option 1: Create a EUL item for each content type. For example, you create a item called gif_content, set the content type to gif, and use decode(type, 'GIF', blob) to populate the item only if the content is gif. Then the user will see multiple hyperlink columns, but only one of the columns will contain a link in each row.
    Option 2: Create a mod_plsql procedure to download the blob. Rather than include the blob in your EUL, instead include a URL that runs your mod_plsql procedure to download the blob. Set the content type for the URL to be FILE and in the procedure set the MIME type using OWA_UTIL.mime_header and download the blob using WPG_DOCLOAD.download_file. Then the user will see one URL hyperlink that will download all file types.
    Hope that helps,
    Rod West

  • Possible Bug in Garbage Collector?

    Hello all
    I'm new to these forums but I searched for this problem and couldn't find exactly the same thing - apologies if I missed something.
    I've written an image browser which displays thumbnails, and when you click on a thumbnail it loads the image in a new window. This new window is just a JFrame, with a single JLabel, with an ImageIcon in it, representing the picture. The path name of the picture is passed when this JFrame is created, and the picture is loaded within the JFrame. Therefore, when I close the JFrame, I expect the memory associated with the image to disappear.
    This works. However, when I open a fairly large image (around 1500x1500 pixels), and then close the window, the garbage collector doesn't free the memory. After this, if i continue to open windows with smaller images, they too have the same problem. However, this doesn't happen with smaller images until I open a larger image.
    I think this is a problem with the garbage collector, is this familiar to anyone? Can anyone help? Unfortunately I can't really paste code since this is a university assignment. But you can try it - just load a jframe with a large picture, close it, and as long as the program runs the memory will not be deallocated.
    Any help would be massively appreciated.
    Thanks

    Since you're not willing to post your code it's very hard to comment.
    One question: Are you calling System.gc() after closing these frames? In fact you should probably call it 3 times to make sure the garbage collector takes you seriously. Try this and let us know if you're still showing the leak

Maybe you are looking for

  • How to determine the structure of parameter method in WebServiceDataControl

    Hi all , I have a web Service Data Control ,this data control has web service method that take a parameter of type (java.lang.Object) how can I determine the structure of this object to send it to the web service method (how can create the object tha

  • Hard Drive and Time Machine backup Different Sizes

    I had a lot of difficulty getting Time Machine to work with my new Time Capsule. It seems to work now but I noticed that on the initial backup the size of the backup data on Time Capsule was roughly 148 GB and my hard drive size is roughly 159 GB. If

  • EAR file download from PI server

    Hi Experts, we have deployed a adapter module in our Quality system sometime back directly from NWDS using SDM. As I didnt had the backup of my EAR file and my system got crashed, i lost the code. Please let me know where can i download(Folder locati

  • Updation problem in custom infotypes.

    HI ALL, I have created two custom infotypes, and the process is that one infotype updates the other infotype. When i open the first infotype by pa30 and then open the second and changes some value which update the first infotype table. now when i go

  • Burning music from music store

    I just bought an album from the iTunes Music Store and tried to burn it to a CD-R but it came up with an error reading "The attempt to burn a disc failed. The device failed to calibrate the laser power level for this media." I don't know what else to