Announcement Announcement Module
Collapse
No announcement yet.
Wierd OutOfMemory problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wierd OutOfMemory problem

    Hello guys,

    I have a wierd problem here, outofmemory error, I was monitoring the linux box where my spring batch program runs and from hardware perspective it just looks fine, so thought will post it here and get inputs from the experts.

    I am reading a file (7GB size) and and writing out that data straight into another file and while doing that I get the following error after it writes out about 600MB of data:

    Code:
    java.lang.OutOfMemoryError: Requested array size exceeds VM limit
    	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:99)
    	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:518)
    	at java.lang.StringBuffer.append(StringBuffer.java:307)
    	at java.io.BufferedReader.readLine(BufferedReader.java:345)
    	at java.io.BufferedReader.readLine(BufferedReader.java:362)
    	at org.springframework.batch.item.file.separator.ResourceLineReader$State.readLine(ResourceLineReader.java:225)
    	at org.springframework.batch.item.file.separator.ResourceLineReader.readLine(ResourceLineReader.java:134)
    	at org.springframework.batch.item.file.separator.ResourceLineReader.read(ResourceLineReader.java:120)
    	at org.springframework.batch.item.file.FlatFileItemReader.readLine(FlatFileItemReader.java:103)
    	at org.springframework.batch.item.file.FlatFileItemReader.doRead(FlatFileItemReader.java:266)
    	at org.springframework.batch.item.support.AbstractBufferedItemReaderItemStream.read(AbstractBufferedItemReaderItemStream.java:92)
    	at org.springframework.batch.item.support.DelegatingItemReader.read(DelegatingItemReader.java:61)
    	at org.springframework.batch.core.step.item.BatchListenerFactoryHelper$1.read(BatchListenerFactoryHelper.java:67)
    	at org.springframework.batch.core.step.item.SimpleItemHandler.doRead(SimpleItemHandler.java:88)
    	at org.springframework.batch.core.step.item.SimpleItemHandler.read(SimpleItemHandler.java:80)
    	at org.springframework.batch.core.step.item.SimpleItemHandler.handle(SimpleItemHandler.java:66)
    	at org.springframework.batch.core.step.item.ItemOrientedStep$2.doInIteration(ItemOrientedStep.java:390)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:346)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.item.ItemOrientedStep.processChunk(ItemOrientedStep.java:383)
    	at org.springframework.batch.core.step.item.ItemOrientedStep$1.doInIteration(ItemOrientedStep.java:251)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:346)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.item.ItemOrientedStep.doExecute(ItemOrientedStep.java:231)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:172)
    	at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:100)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)
    Its a simple Spring Batch job with just one step and here are the readers and writers of my step:

    Code:
    <bean class="org.springframework.batch.item.file.FlatFileItemReader"
    		id="recordItemReader">
    		<property name="resource" ref="inputFileLocator" />
    		<property name="lineTokenizer" ref="inputFileDescriptor" />
    		<property name="fieldSetMapper">
    			<bean
    				class="com.batch.fieldset.mapper.FieldSetMapper" />
    		</property>
    	</bean>
    
    	  
    	<bean id="recordItemWriter"
    		class="com.xx.FileWriter">
    		<property name="fileIemWriter" ref="outputFileWriter" />
    	</bean>
    	
    
    	<bean id="outputFileWriter"
    		class="org.springframework.batch.item.file.FlatFileItemWriter">
    		<property name="resource" ref="outputFileLocator" />
    		<property name="lineAggregator" ref="outputLineAggregator" />
    		<property name="fieldSetCreator">
    			<bean
    				class="com.batch.fieldset.FieldSetCreator" />
    		</property>
    		<property name="bufferSize" value="1000"></property>
    	</bean>
    anyone familiar with this issue? Any guess on what could be going wrong?? Each row is only 160 in length and I have processed files larger than these before.

    Thanks!

  • #2
    What's the size of the commitInterval?

    Comment


    • #3
      commitInterval - 100
      I also tried with commitInterval 1 & 1000

      I am using Spring Batch 1.1.2 and verified that there is enough hard disk and RAM. Any clue on what else I could check?

      I also verified that I do not have any whole or for loop conditions!!!
      Last edited by hailspring; Feb 25th, 2009, 12:13 PM. Reason: additional details

      Comment


      • #4
        Any take on this??? I tried following options:
        1) FlatFileItemReader to FlatFileItemWriter
        2) FlatFileItemReader to ItemWriter which in turn writes to FlatFileItemWriter
        3) FlatFileItemREader to Transformer which in turn writes to FlatFileItemWriter

        I noticed that it is failing on the same line all the time. Even though I am using fixed line tokenizer and field set creator, what could be other problem that it might through OutOfMemory error??

        Appreciate your help! thanks!

        Comment


        • #5
          Are you storing any data in your writer or putting data in the ExecutionContext?

          Comment


          • #6
            Nope, directly writing to a file. No data is being put into Execution Context or the writer.

            It always throw that error at line number: 5647014 , just wanted to put this number here to see whether that has to do anything with the processing.
            Last edited by hailspring; Feb 25th, 2009, 04:21 PM. Reason: updated

            Comment


            • #7
              Here is where it is failing:
              Code:
              at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:99)
              	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:518)
              	at java.lang.StringBuffer.append(StringBuffer.java:307)
              	at java.io.BufferedReader.readLine(BufferedReader.java:345)
              	at java.io.BufferedReader.readLine(BufferedReader.java:362)
              	at org.springframework.batch.item.file.separator.ResourceLineReader$State.readLine(ResourceLineReader.java:225)
              	at org.springframework.batch.item.file.separator.ResourceLineReader.readLine(ResourceLineReader.java:134)
              	at org.springframework.batch.item.file.separator.ResourceLineReader.read(ResourceLineReader.java:120)
              	at org.springframework.batch.item.file.FlatFileItemReader.readLine(FlatFileItemReader.java:103)
              	at org.springframework.batch.item.file.FlatFileItemReader.doRead(FlatFileItemReader.java:266)
              	at org.springframework.batch.item.support.AbstractBufferedItemReaderItemStream.read(AbstractBufferedItemReaderItemStream.java:92)
              	at org.springframework.batch.item.support.DelegatingItemReader.read(DelegatingItemReader.java:61)
              	at org.springframework.batch.core.step.item.BatchListenerFactoryHelper$1.read(BatchListenerFactoryHelper.java:67)
              	at org.springframework.batch.core.step.item.SimpleItemHandler.doRead(SimpleItemHandler.java:88)
              	at org.springframework.batch.core.step.item.SimpleItemHandler.read(SimpleItemHandler.java:80)
              	at org.springframework.batch.core.step.item.SimpleItemHandler.handle(SimpleItemHandler.java:66)
              	at org.springframework.batch.core.step.item.ItemOrientedStep$2.doInIteration(ItemOrientedStep.java:390)
              	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:346)
              	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
              	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
              	at org.springframework.batch.core.step.item.ItemOrientedStep.processChunk(ItemOrientedStep.java:383)
              	at org.springframework.batch.core.step.item.ItemOrientedStep$1.doInIteration(ItemOrientedStep.java:251)
              	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:346)
              	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
              	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
              	at org.springframework.batch.core.step.item.ItemOrientedStep.doExecute(ItemOrientedStep.java:231)
              	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:172)
              	at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:100)
              	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
              	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
              	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)

              Comment


              • #8
                In my profiler, it gives the error stacK in the order as below:

                Code:
                Name
                java.io.BufferedReader.readLine(boolean)
                java.io.BufferedReader.readLine()
                org.springframework.batch.item.file.separator.ResourceLineReader$State.readLine()
                org.springframework.batch.item.file.separator.ResourceLineReader.readLine()
                org.springframework.batch.item.file.separator.ResourceLineReader.read()
                org.springframework.batch.item.file.FlatFileItemReader.readLine()
                org.springframework.batch.item.file.FlatFileItemReader.doRead()
                org.springframework.batch.item.support.AbstractBufferedItemReaderItemStream.read()
                org.springframework.batch.item.support.DelegatingItemReader.read()
                org.springframework.batch.core.step.item.BatchListenerFactoryHelper$1.read()
                org.springframework.batch.core.step.item.SimpleItemHandler.doRead()
                org.springframework.batch.core.step.item.SimpleItemHandler.read(StepContribution)
                org.springframework.batch.core.step.item.SimpleItemHandler.handle(StepContribution)
                org.springframework.batch.core.step.item.ItemOrientedStep$2.doInIteration(RepeatContext)
                org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatContext, RepeatCallback, RepeatInternalState)
                org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatCallback)
                org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatCallback)
                org.springframework.batch.core.step.item.ItemOrientedStep.processChunk(StepExecution, StepContribution)
                org.springframework.batch.core.step.item.ItemOrientedStep$1.doInIteration(RepeatContext)
                org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatContext, RepeatCallback, RepeatInternalState)
                org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatCallback)
                org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatCallback)
                org.springframework.batch.core.step.item.ItemOrientedStep.doExecute(StepExecution)
                org.springframework.batch.core.step.AbstractStep.execute(StepExecution)
                org.springframework.batch.core.job.SimpleJob.execute(JobExecution)
                org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run()
                org.springframework.core.task.SyncTaskExecutor.execute(Runnable)
                org.springframework.batch.core.launch.support.SimpleJobLauncher.run(Job, JobParameters)

                Comment


                • #9
                  One quick question on this.... internally does the FlatFileItemReader users BufferedReader? If yes, does it call its readLine() method? (it seems it does)

                  If it does call readLine() method, does it look for for line separator?? And what does it do if there is no line separator?? I think it tries to read the rest of the file until it finds a line-seprator rite???

                  This file came in from mainframe and since it is failing at BufferredReader I am guessing this could be the problem...... can someone confirm whether I am going in the right direction?

                  Since the file is huge, I cannot view it in my windows system and ask for some mainframe expertise.

                  Thanks!

                  Comment


                  • #10
                    If it isn't a flat file, then I guess you can't use FlatFileItemReader (which as you point out is going to use BufferedReader to read "lines" form the file, which in turn is probably whatever the JDK thinks it is on the platform you are on). What is the structure of your file?

                    Comment


                    • #11
                      Dave, it is text file with 150 characters in each line, it is not fixed length.
                      Also I testing the same program with other files larger than this one and it seems to be working just fine. I still havnt got a chance to see whether that file after that particular line has a new line character. I did profiling and heap, cpu etc is not fully utilized.

                      I will check that file to see whether there is anything specific.

                      Do we have any specific readers for non flat file files??

                      Comment


                      • #12
                        Looks like this file is different then - it must be missing some line endings (what a line ending is in your case I have no idea).

                        Originally posted by hailspring View Post
                        Do we have any specific readers for non flat file files??
                        Not right now. A few people have shown some interest but I haven't seen any JIRAs yet.

                        Comment


                        • #13
                          hmm

                          interesting problem.. I cant think of any solutions either?

                          Comment

                          Working...
                          X