Hallo an alle
Ich versuche eine Tabelle uber 70 Tausend Datensazt zu lesen und in eine ArrayList zu speichern,aber ich bekomme leider am ende ein :
java.lang.OutOfMemoryError: Java heap space und die performance ich auch sehr schlecht 4 Min lese Zeit
der Code:
Code:
Session s1 = HibernateUtil.getSession().openSession();
Query query = s1.createQuery("from Items where Projects_Id =:ProjectsId").setReadOnly(true);
query.setParameter("ProjectsId",Long.valueOf(ProjectId));
query.setCacheMode(CacheMode.IGNORE);
query.setFetchSize(1000);
ScrollableResults userCursorItem = query.scroll(ScrollMode.FORWARD_ONLY);
int Itemreadcount=0;
while(userCursorItem.next()){
Items item = (Items)userCursorItem.get(0);
ItemsDTO itemsdto1=new ItemsDTO();
List<ItemsDTO>lparentdto=new ArrayList<ItemsDTO>(0);
Set<Items>lparentset=new HashSet<Items>();
List<Items>lparent= new ArrayList<Items>();
ItemTypesDTO itemstypesdto=new ItemTypesDTO();
ItemStatusDTO itemstatusdto=new ItemStatusDTO();
AreasDTO areasdto=new AreasDTO();
BudgetHolderDTO budgetholderdto=new BudgetHolderDTO();
CostAllocationsDTO costallocationdto=new CostAllocationsDTO();
PriorityDTO prioritydto=new PriorityDTO();
WeightingsDTO weithingsdto=new WeightingsDTO();
WorkRatingDTO workratingsdto=new WorkRatingDTO();
ProgressDTO progressdto=new ProgressDTO();
ItemsDTO previousitemsdto=new ItemsDTO();
ItemTypesDTO previousitemtypedto=new ItemTypesDTO();
PDMStatusDTO pdmstatusdto=new PDMStatusDTO();
if(item.getPdmstatus()!=null)
{
//pdmstatusdto.setPDMStatusDTO(litem.get(i).getPdmstatus().getPDMStatus());
//pdmstatusdto.setPDMStatusDTO_Id(litem.get(i).getPdmstatus().getPDMStatus_Id());
pdmstatusdto.setPDMStatusDTO(item.getPdmstatus().getPDMStatus());
pdmstatusdto.setPDMStatusDTO_Id(item.getPdmstatus().getPDMStatus_Id());
}
if(item.getItemtypes()!=null)
{
// itemstypesdto.setItemTypesDTO(litem.get(i).getItemtypes().getItemTypes());
// itemstypesdto.setItemTypesDTO_Id(litem.get(i).getItemtypes().getItemTypes_Id());
itemstypesdto.setItemTypesDTO(item.getItemtypes().getItemTypes());
itemstypesdto.setItemTypesDTO_Id(item.getItemtypes().getItemTypes_Id());
}
/*itemstatusdto.setItemStatusDTO(litem.get(i).getItemstatus().getItemStatus());
itemstatusdto.setItemStatusDTO_Id(litem.get(i).getItemstatus().getItemStatus_Id());
itemstatusdto.setOrderDTO(litem.get(i).getItemstatus().getOrder1());*/
itemstatusdto.setItemStatusDTO(item.getItemstatus().getItemStatus());
itemstatusdto.setItemStatusDTO_Id(item.getItemstatus().getItemStatus_Id());
itemstatusdto.setOrderDTO(item.getItemstatus().getOrder1());
....
....
List <ActionDTO>lactiondto1=new ArrayList<ActionDTO>();
for(int j=0;j<lactiondto.size();j++)
{ long ItemId=item.getItems_Id();
long ActionId=lactiondto.get(j).getItemsdto().getItemsDTO_Id();
if((ItemId==ActionId))
{
lactiondto1.add(lactiondto.get(j));
}
}
itemsdto1.setPdmstatusdto(pdmstatusdto);
itemsdto1.setProgressdto(progressdto);
itemsdto1.setLactiondto(lactiondto1);
itemsdto1.setAreadto(areasdto);
itemsdto1.setBudgetholderdto(budgetholderdto);
itemsdto1.setCostallocationsdto(costallocationdto);
itemsdto1.setPrioritydto(prioritydto);
itemsdto1.setWeightingsdto(weithingsdto);
itemsdto1.setWorkratingdto(workratingsdto);
lparentset= item.getParent();
lparent.addAll(lparentset);
for(int y=0;y<lparent.size();y++)
{
ItemsDTO upperitemsdto=new ItemsDTO();
ItemTypesDTO upperitemtypedto=new ItemTypesDTO();
upperitemsdto.setItemsDTO_Id(lparent.get(y).getItems_Id());
upperitemtypedto.setItemTypesDTO(lparent.get(y).getItemtypes().getItemTypes());
upperitemsdto.setIssue(lparent.get(y).getIssue());
upperitemsdto.setIdentifier(lparent.get(y).getIdentifier());
upperitemsdto.setItemtypesdto(upperitemtypedto);
lparentdto.add(upperitemsdto);
upperitemsdto=null;
upperitemtypedto=null;
}
itemsdto1.getParent().addAll(lparentdto);
s1.evict(item);
litemsdto.add(itemsdto1);
itemsdto1=null;
lparentdto=null;
lparentset=null;
lparent= null;
itemstypesdto=null;
itemstatusdto=null;
areasdto=null;
budgetholderdto=null;
costallocationdto=null;
prioritydto=null;
weithingsdto=null;
workratingsdto=null;
progressdto=null;
previousitemsdto=null;
previousitemtypedto=null;
pdmstatusdto=null;
}
Exception:
Starting Jetty on port 8888
[ERROR] Exception while dispatching incoming RPC call
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$LengthConstrainedArray.toString(ServerSerializationStreamWriter.java:96)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.toString(ServerSerializationStreamWriter.java:561)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:619)
at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:474)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:571)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] Out of memory; to increase the amount of memory, use the -Xmx flag at startup (java -Xmx128M ...)
[ERROR] 500 - POST /com.sysberry.sqlportal.AppViewer/LoginService (127.0.0.1) 57 bytes
Request headers
Host: 127.0.0.1:8888
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
X-GWT-Permutation: HostedMode
X-GWT-Module-Base: http://127.0.0.1:8888/com.sysberry.sqlportal.AppViewer/
Content-Type: text/x-gwt-rpc; charset=utf-8
Referer: http://127.0.0.1:8888/AppViewer.html?gwt.codesvr=127.0.0.1:9997
Content-Length: 190
Pragma: no-cache
Cache-Control: no-cache
Response headers
Content-Type: text/plain
Es ist ein Gwt Application ,Datenbank Server: SQLServer 2008
Danke in voraus ..