简体   繁体   English

RMI中的内存不足异常

[英]out of memory exception in RMI

Dear all, I am using java rmi for my program, from client side i am calling my interface method by passing single argument. 亲爱的所有人,我在程序中使用java rmi,从客户端通过传递单个参数来调用接口方法。 Using this argument interface runs a query and returns 40,000 rows(each row containing 10 row)as a result.All these are stored in vector inside vector structure [[0,1,2,3,4,5,6,7,8,9],[],[],[],[],[]...]. 使用此参数接口运行查询并返回40,000行(每行包含10行)。所有这些都存储在vector结构[[0,1,2,3,4,5,6,7,8中,9],[],[],[],[],[] ...]。 This things happen when i am clicking one button. 当我单击一个按钮时,会发生这种事情。 First time its works but again i am trying to do the same (ie clicking button ) It shows java.lang.out of memory exception at client side . 第一次工作,但是我再次尝试做同样的事情(即单击按钮)。它在客户端显示java.lang.out of memory exception pls help me.I am using Postgresql db. 请帮助我。我正在使用Postgresql db。

Client side:
    Vector data = new Vector();
    data = Inter.getEndProductDetailsForCopyChain(endProductId);

Server side:
    public Vector getEndProductDetailsForCopyChain(int endProductId1)
    {
        Connection OPConnect  = StreamLineConnection.GetStreamline_Connection();
        Vector data=new Vector();       
        try{        
            System.out.println("Before query data vector size>>>>>>>>"+data.size());//mohan
            String sqlQry = "select distinct style_no,version_no,matNo,type,specs,color,size,ref_no,uom1 from garment where id=" +endProductId1;
            System.out.println("sqlQry"+ sqlQry);
            Statement st=OPConnect.createStatement();
            ResultSet rs = st.executeQuery(sqlQry);
            while(rs.next()){
                Vector row = new Vector();
                row.add(rs.getString("style_no"));
                row.add(rs.getString("version_no"));
                row.add(rs.getString("matNo"));
                row.add(rs.getString("type"));
                row.add(rs.getString("specs"));
                row.add(rs.getString("color"));
                row.add(rs.getString("size"));
                row.add(rs.getString("ref_no"));
                row.add(rs.getString("uom1"));
                row.add(new Boolean(false));
                data.add(row);
                }
            System.out.println("After query data vector size>>>>>>>>"+data.size());
        }catch(Exception e)
        {    e.printStackTrace();
             closeConnection(OPConnect);
        }
            return data;
       }

I cleared all the vectors and hashmap after finishing my process but still throwing Out of memory exception at client side this happens when data(query result vector) dispatched to client side. 在完成我的过程之后,我清除了所有向量和哈希图,但仍然在客户端抛出内存不足异常,这是在将数据(查询结果向量)调度到客户端时发生的。

A direct response to your question: if you can change the client JVM command line args, then start with more memory allocated. 对您的问题的直接回答:如果可以更改客户端JVM命令行args,则从分配的更多内存开始。 For example, use -Xmx256M to use max memory of 256 Meg 例如,使用-Xmx256M可使用256 Meg的最大内存

A more useful response to your question: The way you phrased your question suggests you know the real problem: a program architecture that tries to obtain so much data on a single click. 对您的问题的更有用的回答:问题表达方式表明您知道真正的问题:一种程序体系结构,单击即可尝试获取大量数据。 Do you really need to have so much data on the client side? 您是否真的需要在客户端拥有如此多的数据? Can you do some processing with it on the server side and send much less? 您可以在服务器端对其进行一些处理并减少发送吗? Can you add paging? 您可以添加分页吗? or lazy loading? 或延迟加载?

Consider Google's search model as a possible solution...a Google search for "hello" has about 310,000,000 matches, yet Google only sends me 10 results at a time. 考虑将Google的搜索模型作为一种可能的解决方案...在Google搜索“ hello”中大约有310,000,000个匹配项,但是Google一次只向我发送10条结果。 Then I click "Next" to get more... this is paging. 然后,我单击“下一步”以获取更多...这是分页。 Users cannot typically make much sense of 40,000 rows of data at once. 用户通常一次无法理解40,000行数据。 Would this work for you? 这对您有用吗?

If this is for export, fetch 100 or so rows at a time, export them, then fetch the next rows... you really don't want to be transferring so much data via RMI in one call. 如果要导出,则一次获取100个左右的行,将其导出,然后获取下一行...您真的不想在一个调用中通过RMI传输这么多数据。

Try to re-use data , do not create a new vector on every request. 尝试重用data ,不要在每个请求上都创建新的向量。 data.clear(); // fill it then data.clear(); // fill it then . data.clear(); // fill it then

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM