OutOfMemoryError with Vectors

Hello,
I am trying to read a lot of data using a database built-in function : search.
The resultset is put into a vector using the following code :
public Vector search (......)
Vector v=new Vector();
LDAPSearchResults res=ld.search(.......);
while ( res.hasMoreElements())
v.addElement((LDAPEntry) results.next());
return v;
When calling the method for 30000 registers : Vector v=search(.......)
I get a OutOfMemorError.
I have tried to capture the OutOfMemoryError in the search Method
public Vector search (...)
try
} catch (OutOfMemoryError e)
System.out.println("No memory!!!");
but it does not work. I still get : java.lang:OutOfMemoryError.
I am calling those functions from the WEB.
THanks for helping.

Hi,
from my experience catching out OutOfMemoryErrors works in JSP as expected.
Following Code runs fine on TomCat 3.21: After the Vector eats up all memory there appears the OutOfMemoryError which is caught by the exception handler.
Could be a problem with you Servlet/JSP container - what are you running? - or the LDAP-Server (?) you are using.
Whether or not you application can do any sensefull in an out-of-memory-situation is the other side of the coin. ;-)
Regards
Martin Schl�ter
<code>
<%@page contentType="text/plain"%>
Plain text JSP
<%
String str = " Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt Hallo Welt";
str += str + str;
str += str + str;
str += str + str;
str += str + str;
Vector vec = new Vector();
for(int i = 0; i < Integer.MAX_VALUE; i++)
try
vec.addElement(str);
catch(OutOfMemoryError ex)
out.println("Ex: " + ex.getClass().getName());
break;
if(i % 100000 == 0)
out.println(i);
out.flush();
%>
</code>

Similar Messages

  • OutOfMemoryError with vector

    Hi,
    My Application uses Vector to store the data.
    The application scenario is such, that the vector size ( due to large number of data ) increases the
    default heap size assigned for that process.
    And as a result the application is throwing OutOfMemoryError.
    Is there any other way of implementing the application.
    How effective serialization of vector will be in this regard?
    Since its related to JMS, corruption of message is my main concern. :-(
    Thanx in advance
    J

    Hi,G'Day
    My Application uses Vector to store the data.Any data in particular?
    The application scenario is such, that the vector size ( due to large number of data ) increases the
    default heap size assigned for that process.This is normal.
    And as a result the application is throwing OutOfMemoryError.This means you should use memory more efficently or increase your memory limit size.
    Is there any other way of implementing the application.Very likely. More details would help.
    How effective serialization of vector will be in this regard?Serialization will help by getting the OutOfMemoryError faster. If this is not desired, it will not help.
    Since its related to JMS, corruption of message is my main concern. :-(I don't see how these issues are related. The message is likely to be lost. I don't see how it can be corrupted.

  • JK Adobe TV - Top 5 Tips for Working with Vectors in CC

    Julieanne Kost has just blogged about her  Adobe TV video on working with shapes and paths in Photoshop CC.  It's actually not that new to Adobe TV, and has already had a lot of views, but we get a lot of questions here on the subject with CC, and there are some nice little tips in it.  I certainly learned a couple of things. :-)
    http://blogs.adobe.com/jkost/2014/01/top-5-tips-for-working-with-vectors-in-photoshop-cc.h tml
    http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/top-5-tips-for-working- with-vectors-in-photoshop-cc/

    My apologies, but I really had no interest in a member's "answer", especially one that is so unhelpful.  Assuming that you were responding to me (we are the only two commenter's at this point), I would not be inclined to read the Creative Cloud offers since this is something that I am not interested in.  I bought the product the first day of offer, I did not rent it....just like I have in all the years past.

  • How can I color fill a sketched/scanned object without tracing it with vectors?

    Is it possible on illustrator or any other programs you know of?
    I've tried using the live paint bucket but it won't color in the sections the way I want. 
    It is a very complex sketch and it's going to take forever if I try to trace it all with vectors.

    This sounds like a job for Photoshop. It's a scan, and you don't want to turn it to vectors, so a vector program like Illustrator is not the best choice in this case.

  • Enlarged Smart Objects with vectors inside them appear as resized bitmaps

    In Photoshop CC for Mac I have...
    Created layers of vector art
    Combined them into a smart object
    Enlarged the smart object (both via "Transform" and "Image Size")
    Upon enlarging, the vector objects look the way an enlarged bitmap would (i.e. fuzzy, pixelated, terrible) instead of crisp and clean as a vector should look. I've double- and triple-checked to make sure all layers have remained vector after resizing and they have.
    This is a terrible inconvenience for anyone that works heavily with vector smart objects and resizes them. I use this workflow on a daily basis to make adapting interface elements for various screen resolutions easier, without it I am beyond screwed.
    If anyone knows a workaround (or if this requires a setting that I haven't found to be changed) please let me know.
    Screenshot proof below:

    Read this thread -link http://forums.adobe.com/message/3498406#3498406
    you may want to read it from the beginning.
    Basically while a smart object layer embedded object may contain  vector graphics.  Photoshop renders a composite for the embedded object and uses the resulting rendered pixels for the smart object layers pixels.  When you transform a smart object layer your transforming those pixels like raster layer using your Photoshop preference interpolation preference..  If you want to resize the vector graphics contained in the embedded object you must open the embedded object into the approbate application and resize the embedded object using vector tools. After you commit the resize. Photoshop will update the embedded object and the layers pixel will be the composite rendered for the updated resized embedded object.

  • Memory leak: critical (blocker) bug with unloading SWF with Vector. T

    Here's the original bugreport https://bugbase.adobe.com/index.cfm?event=bug&id=3071138
    dated december 2011 (add actually appeared even earlier). Despaired of getting any Adobe's team attention I even submitted it again today (as of new releases of FP 11.3 and AIR 3.3 betas).
    Chris Campbell, seems like u're active on this forums. Can you give any feedback?

    This bug has definitely been around a while.  The good news is that it's currently slated "Open / To Fix" for our AIR 3.3 release which is currently up on labs.adobe.com  (our internal number is 3072792).  We've been able to reproduce the problem and our development team is actively investigating.
    The best way to make sure this gets continued focus is to recommend to everyone you know who is affected by this bug to take a minute and cast their vote on the public bug.
    Bug 3071138 - Cannot unload (Loader.unloadAndStop) SWF with Vector.<T>

  • I just got a new macbook pro, i had cs6 on my old macbook, i downloaded cs6 on my new computer today. When I open my illustrator files with vector images they appear blurry on the new computer. I have had this issue in the past and I don't

    i just got a new macbook pro, i had cs6 on my old macbook, i downloaded cs6 on my new computer today. When I open my illustrator files with vector images they appear blurry on the new computer. I have had this issue in the past and I don't

    cnsst,
    Are we talking Edit>Preferences>General>Anti-Aliased Artwork?

  • Problems with vectors

    Hi,
    In response to an earlier problem i posted which i thought i had resolved i have to ask some more advice as i am still having problems.
    Basically i have two points (0,0,0) and (1,1,1) where two spheres are located, im trying to connect a cylinder to these spheres. I have tried using Pythagoras theorem and this connects the spheres up perfectly if the z value is assigned to 0 when i use the rotZ() method with the resulting angle. What i would like to know is there any way of connecting the spheres with 3 coordinates for x,y,z using the same method.
    The main formula i was working on was after connecting up the spheres in just 2 dimensions (ie z value equal to 0) as i mentioned earlier, was to calculate the length of the hypoteneus and have the z value divide this (ie using Pytagoras' theorem again tan teeta = z2-z1/c where c is the sqrt(x*x+y*y) ). Once i got this angle i then rotated it around the Y axis (im not sure if i am actually rotating it around the correct axis, i know that i also have to rotate around the X axis a certain degree but i dont know how much) however the spheres still did not connect up.
    Is it possible to do it the above way or do i need to do i need to use all vector calculations (dot, cross products etc) which i would prefer to stay away from?
    Sorry if it is not very clear it is kind of hard to explain!
    Any help would be greatly appreciated because it is really driving me nuts.
    Regards
    Andy

    Hi
    Just putting up the code to show how i am figuring out the angles and what rotations im using
              double tanTeetaXY = (y-0.0f)/(x-0.0f);
                   double teetaXY = Math.atan(tanTeetaXY);
                   double tanTeetaXZ = (z-0.0f)/(x-0.0f);
                   double teetaXZ = Math.atan(tanTeetaXZ);
                   double testang = (y-0.0f)/(z-0.0f);
                   double teetatest = Math.atan(testang);
                   rotate.rotZ((Math.PI/2.0f)-teetaXY);
                   temprotate.rotY(teetaXZ);
                   rotate.mul(temprotate);
                   temprotate.rotX(teetatest);
                   rotate.mulInverse(temprotate);
                   rotate.invert();Am i completely off with this or is there a better way to figure things out does anyone know? I just cant get my head around it!
    Much appreciated
    Andy

  • Set and get values with vector

    I have a class that that querys a db and sets a value of the result to a vector array. Is it possible to set and retrieve that vector array using the set and get methods?
    ex:
    my class:
    sql = "Select ...";
    Vector fName = new Vector();
    rs = sqlStatement.executeQuery(sql);
    if (rs != null) {
    while (rs.next()) {
    fName.add(rs.getString("fName") + "");
    rs.close();
    setFName(fName);
    how would I set up the set and get methods???
    thanks

    I am unsure of what you are asking:
    A Vector has set and get methods for it, you use indexes of the array to say what element you want to work with.
    If you are asking how do you know what elements of the Vector contain which data columns, you have to remember how you put them in.
    If you are asking if you can use set to load the Vector: then NO, you have to have elemenets already there to change, use the add method.
    If you are asking how to access the elements of the Vector you use an Enumeration:
    for(java.util.Enumeration e = v.elements(); e.hasMoreElements();){
    s = (java.lang.String) e.nextElement();
    vl.add(s.substring(0, 12));
    If you are asking something else: please elaborate what you want--my brain may not be very functional this morning.

  • Replacing bitmap text with vector graphic text

    In a layout for an ebook I have some important black and white bitmap illustrations in tiff., 300 dpi. These have appeared ok on print, but on screen, reading the same pdf-file, they´re unacceptable, especially some texts in fontsize 5-6 pt are unclear. People tell me I have to convert the drawings, or at least the texts, to vector graphics.
    Question: Can I open these tiff.s in Photoshop, change only the texts to vector graphics and then save in a format, that can be inserted in the Word2010 layout? (You might wonder why I use Word, but it was a question of economy, when the project was started up). Or are there other ways? Thanks for any answers!

    You are right, there are no layers, some geometric shapes with texts in and around. It´s possible to mark or lassoe the bits of text, since spaces were made in the figures for the texts. And then delete them, and then insert new ones. That will be in another layer, I guess, but from that point I don´t know what to do :-)

  • Exporting to PDF with Vector/Transparency issues? (huge file)

    Hi folks
    I have a 36 page magazine in Indesign which has a lot of illustrator images placed in, some of which have transparency applied.  The images are xmas icons and there are 10 or so on each illustrator file so there are only 3/4 illustrator files placed but they are done many times over within the Indesign file.
    When I export to PDF the file size is huge.  154mb.  I am sure it is to do with the vectors/transparency, but dont know how to correct this to bring the PDF file size down.  Any ideas?
    Thanks

    To echo Peter's response, 154 MB for a 36 page magazine is not necessarily all that large, especially if the content is graphically rich.
    There is some information you are not providing us. For example, how are you bringing in the Illustrator artwork? And with what settings are you exporting PDF?
    In the first case, the most efficient way to bring Illustrator content into InDesign is to save the Illustrator artwork as PDF/X-4 and place the resultant file into InDesign. InDesign is more likely to reuse the content for PDF export if the content is placed in that manner.
    In the second case, content with transparency can yield very bloated PDF if you export PDF with flattened transparency such as you would get with the PDF/X-1a or PDF/X-3 export settings from InDesign (or for the Illustrator-based imported content, PDF saved from Illustrator with such settings). Again, we recommend PDF/X-4 for PDF export maintaining live transparency and original color spaces with ICC profiles and avoiding the bloat caused by transparency flattening and conversion of RGB to CMYK.
              - Dov

  • Fill JComboBox with Vector from database

    Hi there,
    I have a problem with filling a JComboBox with data from a database. I can print the data in the console, but it seems to be impossible to do it in a ComboBox ...
    I tried this:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    *package client;*
    *import data.Raum;*
    *import data.RaumImpl;*
    *import java.net.MalformedURLException;*
    *import java.rmi.Naming;*
    *import java.rmi.NotBoundException;*
    *import java.rmi.RemoteException;*
    *import java.sql.SQLException;*
    *import javax.swing.JComboBox;*
    *import javax.swing.JFrame;*
    *import java.util.Vector;*
    *import verwaltung.*;
    import server.DraServer;
    * @author philipp
    public class ComboBox extends JFrame
        ComboBox(String title) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
        super(title);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        DraVerwaltung verwaltung = (DraVerwaltung) Naming.lookup ("rmi://localhost/DRA");
        System.out.println("Remote object created...");
        Vector raeume = verwaltung.RaumAusleser();
        Raum r;
        for (int i = 0; i < raeume.size(); i++)
            r = (Raum)raeume.elementAt(i);
    //      System.out.println ("Raum: " + r.getRaumname());
    //      System.out.println ("Raumid: " + r.getIdRaum());
         JComboBox jcb = new JComboBox(r.getRaumname());
        getContentPane().add(jcb);
        setSize(200, 50);
        setVisible(true);      
      public static void main(String[] args) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
        new ComboBox("Test");
    }In this case I get the following for JComboBox (line 44):
    "cannot find symbol
    symbol: constructor JComboBox(java.lang.string)
    location: class javax.swing.JComboBox"
    I tried:
    -> change "JComboBox jcb = new JComboBox(r.getRaumname());" to "JComboBox jcb = new JComboBox(raeume);"
    then I got the JComboBox, but with ... I don't know how to describe the content. It seems like a (very long) reference.
    All other tries can't be tested, because I got the problem with constructor again.
    I'm happy for an early response.
    Regards

    Now, it works!
    It looks like that:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package client;
    import data.Raum;
    import data.RaumImpl;
    import java.net.MalformedURLException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.sql.SQLException;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import java.util.Vector;
    import verwaltung.*;
    import server.DraServer;
    * @author philipp
    public class ComboBox extends JFrame
        ComboBox(String title) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
        super(title);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        DraVerwaltung verwaltung = (DraVerwaltung) Naming.lookup ("rmi://localhost/DRA");
        System.out.println("Remote object created...");
        Vector raeume = verwaltung.RaumAusleser();
        Raum r = new RaumImpl();
        Vector vJcb = new Vector();
        for (int i = 0; i < raeume.size();i++){
            r = (Raum)raeume.elementAt(i); 
            vJcb.add(r.getRaumname());
        JComboBox jcb = new JComboBox(vJcb);
        getContentPane().add(jcb);
        setSize(200, 50);
        setVisible(true);     
        public static void main(String[] args) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
           new ComboBox("Combo box Demo1");
    }Thanks in advantage to all!

  • PROBLEM WITH VECTORS

    i NEED SOME HELP HERE. I HAVE TRIED DIFFERENT METHODS, BUT I CAN'T SEEM TO GET IT RIGHT
    int location = -1;///TODO: SET location = INDEX OF ITEM WITH A VALUE X
    list.remove(5);
    print("Item equal to 6 removed", list);
    ///TODO: ADD 9 TO LIST AT POSITION 2 AND ADD 123 TO END OF LIST
    list.add(new Integer (99));
    print("Added 44 at 4 and 99 at end", list);
    add1ToAll(list);
    print("1 added to each", list);
    static void print(String message, Vector v)
    System.out.print(message + ": {");
    for(int i = 0; i < v.size() - 1; i++)
    System.out.print(v.get(i) + ", ");
    System.out.println(v.get(v.size() - 1) + "}");
    static void add1ToAll(Vector v)
    ///TODO: ADD 1 TO EACH NUMBER IN VECTOR v

    1) are you using the (new Integer()); I think that there is a difference between Integer and int;
    2) I found that using a Vector with images is easier if you add it as a String like this (vector.add(""+foo));
    and then convert it back upon usage eg.
    int x = Integer.parseInt((String)vect.get());
    or something like that. I am not around my development
    enviroment at this time.
    --Ian                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem with Vector method addElement

    I am new to Java. I am using JDK 1.3. I am writing a program that will convert a text file to a binary file that stores a Vector object. I have narrowed my problem to the method that reads the text file and creates my vector. Each element in my vector stores an integer and a string variable. The reading of the text file works find and the creation of my record works find. It seems that the storing of the record in the vector is not working. When I print the first 10 elements of the vector, it have the same record(the last record of my text file). What is wrong with the method below? I am also appending the result of running my program.
    private static void readTextFile(File f) {
    try {
    FileReader fileIn = new FileReader(f);
    BufferedReader in = new BufferedReader(fileIn);
    String line;
    int i;
    SsnLocationRecord recordIn = new SsnLocationRecord();
    int ctr = 0;
    while (true) {
    line = in.readLine();
    if (line == null)
    break;
    ctr += 1;
    i = line.indexOf(" ");
    recordIn.putAreaNumber(Integer.parseInt(line.substring(0,i).trim()));
    recordIn.putLocation(line.substring(i+1).trim());
    records.addElement(recordIn);
    if (ctr < 11)
    System.out.println(recordIn);
    in.close();
    } catch (IOException e) {
    System.out.println ("Error reading file");
    System.exit(0);
    for (int i = 0; i < 11; i++)
    System.out.println((SsnLocationRecord) records.elementAt(i));
    RESULTS:
    C:\Training\Java>java ConvertTextFileToObjectFile data\ssn.dat
    0 null
    3 New Hampshire
    7 Maine
    9 Vermont
    34 Massachusetts
    39 Rhode Island
    49 Connecticut
    134 New York
    158 New Jersey
    211 Pennsylvania
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    680 Nevada
    C:\Training\Java>

    First of all it would be better if you did a priming read and then checked line == null in the while statement instead of the way you have it.
    ctr++ will also accomplish what ctr +=1 is doing.
    you need to create a new instance of SsnLocationRecord for each line read. What you are doing is overlaying the objects data each time you execute the .putxxxx methods. The reference to the object is placed in the vector. The actual object is still being updated by the .putxxx methods (NOTE : THIS IS THE ANSWER TO YOUR MAIN QUESTION).
    you close should be in a finally statement.
    To process through all the elements of a Vector create an Enumeration and then use the nextElement() method instead of the elementAt is probably better. (Some will argue with me on this I am sure).
    Also, on a catch do not call System.exit(0). This will end your JVM normally. Instead throw an Exception (Runtime or Error level if you want an abnormal end).

  • Performance of ArrayList with Vectors

    Tell me any one that , is ArrayList Performance is Better then Vectors ? and if yes why so?

    yes, again. As long as authors of introductory tests don't stop using Vector in their examples and Sun doesn't change the Swing method arguments to take a List instead of hardcoding a Vector (enabling people to finally abandong the thing without recoding every ListModel, TableModel, etc. they want to use) we'll keep seeing this.
    Vector should be deprecated, in fact it should have been removed already (maybe with the name just becoming a wrapper for a synchronized ArrayList to maintain backwards compatibility for a few releases).

Maybe you are looking for