You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Alberto Pedrera <me...@hotmail.com> on 2010/04/07 16:36:19 UTC

Process java memory

Hi all.

I have this code.

public static void main(String[] args) throws Exception{
	try{			
		File input = new File("D:/test.xlsx");
		System.out.println("Open the file");			
		Workbook wb = new XSSFWorkbook(new FileInputStream(input));
		System.out.println("Open correctly");			
		while(true){	
			System.out.println("Clean the memory");
			System.gc();
		}			
	}catch(Exception e){
		log.error("Error Main", e);
	}
}

My java process needs great deal of memory but when it executes "clean the
memory" this memory is never liberate. Test.xlsx has 25000 lines and 50
columns and memory consume is 1300MB.
Someone can help me?

Best regards.
Alberto.
-- 
View this message in context: http://old.nabble.com/Process-java-memory-tp28165914p28165914.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Process java memory

Posted by Richard Holmes <ri...@shedconsulting.co.uk>.
I tried this and checked the results using gcviewer and the startup options:

-verbose:gc -Xloggc:D:/AribaDev/xmlFrameworkTests/gctest/test.gc
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps

It showed that the memory usage went up to 190,000k usage and then after
first GC it droped to 100,000k then the memory used by the Java app sat at
130,000K and the memory actually used was 100,000k.

I think this looks about right for how it should be used. I did check that
file handles were closed.

Hope this helps
Regards
Richard

On 10 April 2010 16:57, Robert Lowe <ro...@rmlowe.com> wrote:

> Alberto, I think you might be misunderstanding what garbage collection
> actually does. My understanding is that garbage collection will never
> reduce
> the amount of memory allocated to the JVM, it simply attempts to free space
> on the heap within the JVM for use by other Java objects. - Rob
>
>
> On Wed, Apr 7, 2010 at 10:36 PM, Alberto Pedrera <melkor_91@hotmail.com
> >wrote:
>
> >
> > Hi all.
> >
> > I have this code.
> >
> > public static void main(String[] args) throws Exception{
> >        try{
> >                File input = new File("D:/test.xlsx");
> >                System.out.println("Open the file");
> >                Workbook wb = new XSSFWorkbook(new
> FileInputStream(input));
> >                System.out.println("Open correctly");
> >                while(true){
> >                        System.out.println("Clean the memory");
> >                        System.gc();
> >                }
> >        }catch(Exception e){
> >                log.error("Error Main", e);
> >        }
> > }
> >
> > My java process needs great deal of memory but when it executes "clean
> the
> > memory" this memory is never liberate. Test.xlsx has 25000 lines and 50
> > columns and memory consume is 1300MB.
> > Someone can help me?
> >
> > Best regards.
> > Alberto.
> > --
> > View this message in context:
> > http://old.nabble.com/Process-java-memory-tp28165914p28165914.html
> > Sent from the POI - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> >
> >
>

Re: Process java memory

Posted by Robert Lowe <ro...@rmlowe.com>.
Alberto, I think you might be misunderstanding what garbage collection
actually does. My understanding is that garbage collection will never reduce
the amount of memory allocated to the JVM, it simply attempts to free space
on the heap within the JVM for use by other Java objects. - Rob


On Wed, Apr 7, 2010 at 10:36 PM, Alberto Pedrera <me...@hotmail.com>wrote:

>
> Hi all.
>
> I have this code.
>
> public static void main(String[] args) throws Exception{
>        try{
>                File input = new File("D:/test.xlsx");
>                System.out.println("Open the file");
>                Workbook wb = new XSSFWorkbook(new FileInputStream(input));
>                System.out.println("Open correctly");
>                while(true){
>                        System.out.println("Clean the memory");
>                        System.gc();
>                }
>        }catch(Exception e){
>                log.error("Error Main", e);
>        }
> }
>
> My java process needs great deal of memory but when it executes "clean the
> memory" this memory is never liberate. Test.xlsx has 25000 lines and 50
> columns and memory consume is 1300MB.
> Someone can help me?
>
> Best regards.
> Alberto.
> --
> View this message in context:
> http://old.nabble.com/Process-java-memory-tp28165914p28165914.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Process java memory

Posted by Nick Burch <ni...@alfresco.com>.
On Fri, 9 Apr 2010, Alberto Pedrera wrote:
> Thanks for you attention. Yes, I have tempted to get 3.6 but 
> unfortunately the problem is present.

I'd suggest you get a profiler (many of them have free trials for 
example), and run your app under that. Hopefully that'll give you some 
ideas on where the memory gets lost

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Process java memory

Posted by Alberto Pedrera <me...@hotmail.com>.
Hi Mark.

Thanks for you attention. Yes, I have tempted to get 3.6 but unfortunately
the problem is present. I hope that someone identify a possible solution for
this issue.



MSB wrote:
> 
> Hello again Alberto,
> 
> I must admit that I would be tempted to get 3.6 or even the latest release
> of 3.7 to see if that helps at all though I do have to admit that I cannot
> say definitively that it will. The ooxml stream of the api which is used
> to process the newer xml based Excel files is very memory hungry largly
> due to the number of objects that are required to successfully parse the
> file I believe.
> 
> It will be worth while having a search through the lists - both user and
> dev - as I am certain there will be other posts related to this issue. It
> may be the case that someone else has identified a possible solution to
> the the problem that you are facing. Unfortunately, I do not use this
> stream of the api regularly - well only when trying to develop examples
> for other users which are by their nature small - and so cannot really
> offer any further advise aside from recommending that you take a look at
> the eventusermode rather than the usermodel. Typically, applications that
> use the eventusermodel have a much smaller memory requirement.
> 
> Yours
> 
> Mark B
> 
> 
> Alberto Pedrera wrote:
>> 
>> Hi Mark.
>> 
>> I´m using the version of POI 3.5 and Java 1.6.0_14.
>> 
>> Thanks in advance.
>> 
>> 
>> MSB wrote:
>>> 
>>> Hello Alberto,
>>> 
>>> Can I ask please which version of POI are you using? I know that there
>>> was a problem with releasing file handles in an earlier version of the
>>> api so it may be worth while downloading and using the very latest
>>> version if you are not already doing so.
>>> 
>>> Yours
>>> 
>>> Mark B
>>> 
>>> 
>>> Alberto Pedrera wrote:
>>>> 
>>>> Hi all.
>>>> 
>>>> I have this code.
>>>> 
>>>> public static void main(String[] args) throws Exception{
>>>> 	try{			
>>>> 		File input = new File("D:/test.xlsx");
>>>> 		System.out.println("Open the file");			
>>>> 		Workbook wb = new XSSFWorkbook(new FileInputStream(input));
>>>> 		System.out.println("Open correctly");			
>>>> 		while(true){	
>>>> 			System.out.println("Clean the memory");
>>>> 			System.gc();
>>>> 		}			
>>>> 	}catch(Exception e){
>>>> 		log.error("Error Main", e);
>>>> 	}
>>>> }
>>>> 
>>>> My java process needs great deal of memory but when it executes "clean
>>>> the memory" this memory is never liberate. Test.xlsx has 25000 lines
>>>> and 50 columns and memory consume is 1300MB.
>>>> Someone can help me?
>>>> 
>>>> Best regards.
>>>> Alberto.
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Process-java-memory-tp28165914p28189059.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Process java memory

Posted by MSB <ma...@tiscali.co.uk>.
Hello again Alberto,

I must admit that I would be tempted to get 3.6 or even the latest release
of 3.7 to see if that helps at all though I do have to admit that I cannot
say definitively that it will. The ooxml stream of the api which is used to
process the newer xml based Excel files is very memory hungry largly due to
the number of objects that are required to successfully parse the file I
believe.

It will be worth while having a search through the lists - both user and dev
- as I am certain there will be other posts related to this issue. It may be
the case that someone else has identified a possible solution to the the
problem that you are facing. Unfortunately, I do not use this stream of the
api regularly - well only when trying to develop examples for other users
which are by their nature small - and so cannot really offer any further
advise aside from recommending that you take a look at the eventusermode
rather than the usermodel. Typically, applications that use the
eventusermodel have a much smaller memory requirement.

Yours

Mark B


Alberto Pedrera wrote:
> 
> Hi Mark.
> 
> I´m using the version of POI 3.5 and Java 1.6.0_14.
> 
> Thanks in advance.
> 
> 
> MSB wrote:
>> 
>> Hello Alberto,
>> 
>> Can I ask please which version of POI are you using? I know that there
>> was a problem with releasing file handles in an earlier version of the
>> api so it may be worth while downloading and using the very latest
>> version if you are not already doing so.
>> 
>> Yours
>> 
>> Mark B
>> 
>> 
>> Alberto Pedrera wrote:
>>> 
>>> Hi all.
>>> 
>>> I have this code.
>>> 
>>> public static void main(String[] args) throws Exception{
>>> 	try{			
>>> 		File input = new File("D:/test.xlsx");
>>> 		System.out.println("Open the file");			
>>> 		Workbook wb = new XSSFWorkbook(new FileInputStream(input));
>>> 		System.out.println("Open correctly");			
>>> 		while(true){	
>>> 			System.out.println("Clean the memory");
>>> 			System.gc();
>>> 		}			
>>> 	}catch(Exception e){
>>> 		log.error("Error Main", e);
>>> 	}
>>> }
>>> 
>>> My java process needs great deal of memory but when it executes "clean
>>> the memory" this memory is never liberate. Test.xlsx has 25000 lines and
>>> 50 columns and memory consume is 1300MB.
>>> Someone can help me?
>>> 
>>> Best regards.
>>> Alberto.
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Process-java-memory-tp28165914p28188900.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Process java memory

Posted by Alberto Pedrera <me...@hotmail.com>.
Hi Mark.

I´m using the version of POI 3.5 and Java 1.6.0_14.

Thanks in advance.


MSB wrote:
> 
> Hello Alberto,
> 
> Can I ask please which version of POI are you using? I know that there was
> a problem with releasing file handles in an earlier version of the api so
> it may be worth while downloading and using the very latest version if you
> are not already doing so.
> 
> Yours
> 
> Mark B
> 
> 
> Alberto Pedrera wrote:
>> 
>> Hi all.
>> 
>> I have this code.
>> 
>> public static void main(String[] args) throws Exception{
>> 	try{			
>> 		File input = new File("D:/test.xlsx");
>> 		System.out.println("Open the file");			
>> 		Workbook wb = new XSSFWorkbook(new FileInputStream(input));
>> 		System.out.println("Open correctly");			
>> 		while(true){	
>> 			System.out.println("Clean the memory");
>> 			System.gc();
>> 		}			
>> 	}catch(Exception e){
>> 		log.error("Error Main", e);
>> 	}
>> }
>> 
>> My java process needs great deal of memory but when it executes "clean
>> the memory" this memory is never liberate. Test.xlsx has 25000 lines and
>> 50 columns and memory consume is 1300MB.
>> Someone can help me?
>> 
>> Best regards.
>> Alberto.
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Process-java-memory-tp28165914p28188559.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Process java memory

Posted by Ramin Assisi <ra...@googlemail.com>.
Hello,

there is a problem with all tests which try to put a resource into an
ooxml document. The tests check only if there is a resource. But the
resource
have always 0 bytes in the OPCPackage (see for instance
poi.openxml4j.opc.TestPackageThumbnail).

Has anyone an idea how to write a resource into OPCPackage correctly?

Thanks for any help.

Ramin


http://joffice.eu

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Process java memory

Posted by MSB <ma...@tiscali.co.uk>.
Hello Alberto,

Can I ask please which version of POI are you using? I know that there was a
problem with releasing file handles in an earlier version of the api so it
may be worth while downloading and using the very latest version if you are
not already doing so.

Yours

Mark B


Alberto Pedrera wrote:
> 
> Hi all.
> 
> I have this code.
> 
> public static void main(String[] args) throws Exception{
> 	try{			
> 		File input = new File("D:/test.xlsx");
> 		System.out.println("Open the file");			
> 		Workbook wb = new XSSFWorkbook(new FileInputStream(input));
> 		System.out.println("Open correctly");			
> 		while(true){	
> 			System.out.println("Clean the memory");
> 			System.gc();
> 		}			
> 	}catch(Exception e){
> 		log.error("Error Main", e);
> 	}
> }
> 
> My java process needs great deal of memory but when it executes "clean the
> memory" this memory is never liberate. Test.xlsx has 25000 lines and 50
> columns and memory consume is 1300MB.
> Someone can help me?
> 
> Best regards.
> Alberto.
> 

-- 
View this message in context: http://old.nabble.com/Process-java-memory-tp28165914p28188213.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org