You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Miroslav F." <mi...@seznam.cz> on 2011/08/05 18:20:10 UTC

tomcat eats memory

Hi folks,

I have these classes:

package com.myapp;
public class Minerals extends WebPage{
	public Minerals(){
		RepeatingView repeater = new RepeatingView("repeater");
		//data from database - images and descriptions
		ArrayList dataFromDB = (new ImagesMinerals()).load();
		//descriptions
		ArrayList desc = new ArrayList();
		desc = (ArrayList) dataFromDB.get(0);
		//images
		ArrayList images = new ArrayList();
		images = (ArrayList) dataFromDB.get(1);
		int size = images.size();
		for(int i = 0; i < size; i++){
			String repeaterID = repeater.newChildId();
			ImageRepeater repeaterChild = new
ImageRepeater(repeaterID);
			//add description
			repeaterChild.add(new Label("description", (String)
desc.get(i)));
			//add image
			DBImage image = new DBImage();
			image.setImageData((byte[]) images.get(i));
			//not caching on browser
			Double random = Math.random();
			//put shared resource (image) on clean path
			Start.get().getSharedResources().add("image" +
random.toString() + ".jpg", image);
			ResourceReference imageResource = new
ResourceReference("image" + random.toString() + ".jpg");
			String url =
RequestCycle.get().urlFor(imageResource).toString();
			//href in <a> and src in <img> should have same path
because lightbox won't work...
			ExternalLink odkaz = new ExternalLink("anchor",
url);
			WebMarkupContainer imageSrcAttribute = new
WebMarkupContainer("image");
			imageSrcAttribute.add(new AttributeModifier("src",
new Model<String>(url)));
			odkaz.add(imageSrcAttribute);
			odkaz.add(new SimpleAttributeModifier("title",
(String) desc.get(i)));
			repeaterChild.add(odkaz);
			repeater.add(repeaterChild);
		}
		this.add(repeater);
	}
}

package com.myapp;
public class ImagesMinerals extends
LoadableDetachableModel<ArrayList<byte[]>>{
	@Override
	protected ArrayList load(){
		DBGetImages databaseMinerals = new DBGetImages();
		ArrayList dataMineraly = databaseMinerals.getData();
		return dataMinerals;
	}
}

My problem is that when i again and again click on page the memory in tomcat
is eaten and I end-up with 
Java heap space error. Doesn't matter if heap is 64MB or 1GB on start, after
some clicks memory is eaten.

Somethink wrong with my LDM?

Miro


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: tomcat eats memory

Posted by Dan Retzlaff <dr...@gmail.com>.
Construct a ResourceLink with the same ResourceReference as your Image.

On Fri, Aug 5, 2011 at 11:06 AM, Miroslav F. <mi...@seznam.cz> wrote:

> With this I have problem that then I need to take url from Image component
> and put it into Link component:
> <a      href="#" <!-- <-this atribute --> wicket:id="anchor"
>                        rel="lightbox"
>                        title="">
>                                <img    style="border: 3px solid #DCD4A7;
> padding: 1px 1px 1px 1px; width: 199px; height: 149px;" alt="" src="" <!--
> <-and this atribute -->
>                                                wicket:id="image">
>                </a>
> <!-- have to had the same url + .jpg at the end. Otherwise Lightbox won't
> work -->
>
> No problem make Image component as in example (my first attempt was same)
> but not know how then take url from image component and put into Link
> component.
>
>
>
> > -----Original Message-----
> > From: Dan Retzlaff [mailto:dretzlaff@gmail.com]
> > Sent: Friday, 05. August 2011 19:58
> > To: users@wicket.apache.org
> > Subject: Re: tomcat eats memory
> >
> > It sounds like a shared resource is not the right solution
> > for your problem.
> > Just throw a wicket:id on your Lightbox image tag and create
> > a Wicket Image like "image5" of the wicketstuff examples link I sent.
> >
> > On Fri, Aug 5, 2011 at 10:46 AM, Miroslav F. <mi...@seznam.cz> wrote:
> >
> > > Answer myself: should be solution before
> > > Start.get().getSharedResources().add("image" + random.toString() +
> > > ".jpg", image); do something like "unmount all previosly mounted
> > > images"?
> > >
> > > In Application.init() isn't possible to mount them - I don't know
> > > which page user click. In database is around 1.000 images and there
> > > are on around 100 pages (every page has around 10 images).
> > For me it
> > > looks crazy in Application.init() take all images from DB and mount
> > > them.
> > >
> > >
> > > > -----Original Message-----
> > > > From: Miroslav F. [mailto:mirfok@seznam.cz]
> > > > Sent: Friday, 05. August 2011 18:54
> > > > To: users@wicket.apache.org
> > > > Subject: RE: tomcat eats memory
> > > >
> > > > Using non-shared images? My problem is that I need same
> > url for href
> > > > in <a> and for src in <img> for lightbox to work.
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Dan Retzlaff [mailto:dretzlaff@gmail.com]
> > > > > Sent: Friday, 05. August 2011 18:45
> > > > > To: users@wicket.apache.org
> > > > > Subject: Re: tomcat eats memory
> > > > >
> > > > > This is your problem:
> > > > >
> > > > > Start.get().getSharedResources().add("image" +
> > > > > > random.toString() + ".jpg", image);
> > > > >
> > > > >
> > > > > Adding shared resources during page construction is
> > very unusual.
> > > > > Consider registering shared resources in
> > > > Application.init(), or using
> > > > > non-shared images. Refer to
> > http://wicketstuff.org/wicket/images/
> > > > >
> > > > > On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F.
> > > > <mi...@seznam.cz> wrote:
> > > > >
> > > > > > Hi folks,
> > > > > >
> > > > > > I have these classes:
> > > > > >
> > > > > > package com.myapp;
> > > > > > public class Minerals extends WebPage{
> > > > > >        public Minerals(){
> > > > > >                RepeatingView repeater = new
> > > > > RepeatingView("repeater");
> > > > > >                //data from database - images and descriptions
> > > > > >                ArrayList dataFromDB = (new
> > > > ImagesMinerals()).load();
> > > > > >                //descriptions
> > > > > >                ArrayList desc = new ArrayList();
> > > > > >                desc = (ArrayList) dataFromDB.get(0);
> > > > > >                //images
> > > > > >                ArrayList images = new ArrayList();
> > > > > >                images = (ArrayList) dataFromDB.get(1);
> > > > > >                int size = images.size();
> > > > > >                for(int i = 0; i < size; i++){
> > > > > >                        String repeaterID =
> > repeater.newChildId();
> > > > > >                        ImageRepeater repeaterChild = new
> > > > > > ImageRepeater(repeaterID);
> > > > > >                        //add description
> > > > > >                        repeaterChild.add(new
> > > > > > Label("description",
> > > > > > (String) desc.get(i)));
> > > > > >                        //add image
> > > > > >                        DBImage image = new DBImage();
> > > > > >                        image.setImageData((byte[])
> > images.get(i));
> > > > > >                        //not caching on browser
> > > > > >                        Double random = Math.random();
> > > > > >                        //put shared resource (image) on clean
> > > > > > path
> > > > > >
> > > > > Start.get().getSharedResources().add("image" +
> > > > > > random.toString() + ".jpg", image);
> > > > > >                        ResourceReference imageResource = new
> > > > > > ResourceReference("image" + random.toString() + ".jpg");
> > > > > >                        String url =
> > > > > > RequestCycle.get().urlFor(imageResource).toString();
> > > > > >                        //href in <a> and src in <img>
> > > > > should have same
> > > > > > path because lightbox won't work...
> > > > > >                        ExternalLink odkaz = new
> > > > > ExternalLink("anchor",
> > > > > > url);
> > > > > >                        WebMarkupContainer imageSrcAttribute =
> > > > > > new WebMarkupContainer("image");
> > > > > >                        imageSrcAttribute.add(new
> > > > > > AttributeModifier("src", new Model<String>(url)));
> > > > > >                        odkaz.add(imageSrcAttribute);
> > > > > >                        odkaz.add(new
> > > > > SimpleAttributeModifier("title",
> > > > > > (String) desc.get(i)));
> > > > > >                        repeaterChild.add(odkaz);
> > > > > >                        repeater.add(repeaterChild);
> > > > > >                }
> > > > > >                this.add(repeater);
> > > > > >        }
> > > > > > }
> > > > > >
> > > > > > package com.myapp;
> > > > > > public class ImagesMinerals extends
> > > > > > LoadableDetachableModel<ArrayList<byte[]>>{
> > > > > >        @Override
> > > > > >        protected ArrayList load(){
> > > > > >                DBGetImages databaseMinerals = new
> > DBGetImages();
> > > > > >                ArrayList dataMineraly =
> > > > databaseMinerals.getData();
> > > > > >                return dataMinerals;
> > > > > >        }
> > > > > > }
> > > > > >
> > > > > > My problem is that when i again and again click on page the
> > > > > memory in
> > > > > > tomcat is eaten and I end-up with Java heap space
> > error. Doesn't
> > > > > > matter if heap is 64MB or 1GB on start, after some clicks
> > > > memory is
> > > > > > eaten.
> > > > > >
> > > > > > Somethink wrong with my LDM?
> > > > > >
> > > > > > Miro
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > --------------------------------------------------------------------
> > > > -
> > > > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > --------------------------------------------------------------------
> > > > - To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: tomcat eats memory

Posted by Bas Gooren <ba...@iswd.nl>.
Actually, I think mounting a custom resource _is_ the way to go.

To keep things simple, let me suggest two options:

(1) Create a custom resource which serves the correct image based on a 
url parameter (see WebResource)
This will allow you to generate user-friendly urls to your images

(2) Create a custom component which implements IResourceListener; You 
can then generate a session-specific url for this component, which when 
requested by a browser will call onResourceRequested(). You can then 
send the image based on component-specific variables, e.g. a database-id;

(1) has the benefit of non-session-specific (seo-friendly) urls
(2) has the benefit of having all image related functionality in a 
single component (both generating the url and serving the image)

Bas

Op 5-8-2011 19:58, schreef Dan Retzlaff:
> It sounds like a shared resource is not the right solution for your problem.
> Just throw a wicket:id on your Lightbox image tag and create a Wicket Image
> like "image5" of the wicketstuff examples link I sent.
>
> On Fri, Aug 5, 2011 at 10:46 AM, Miroslav F.<mi...@seznam.cz>  wrote:
>
>> Answer myself: should be solution before
>> Start.get().getSharedResources().add("image" + random.toString() + ".jpg",
>> image);
>> do something like "unmount all previosly mounted images"?
>>
>> In Application.init() isn't possible to mount them - I don't know which
>> page
>> user click. In database is around 1.000 images
>> and there are on around 100 pages (every page has around 10 images). For me
>> it looks crazy in Application.init() take all images
>> from DB and mount them.
>>
>>
>>> -----Original Message-----
>>> From: Miroslav F. [mailto:mirfok@seznam.cz]
>>> Sent: Friday, 05. August 2011 18:54
>>> To: users@wicket.apache.org
>>> Subject: RE: tomcat eats memory
>>>
>>> Using non-shared images? My problem is that I need same url
>>> for href in<a>  and for src in<img>  for lightbox to work.
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Dan Retzlaff [mailto:dretzlaff@gmail.com]
>>>> Sent: Friday, 05. August 2011 18:45
>>>> To: users@wicket.apache.org
>>>> Subject: Re: tomcat eats memory
>>>>
>>>> This is your problem:
>>>>
>>>> Start.get().getSharedResources().add("image" +
>>>>> random.toString() + ".jpg", image);
>>>>
>>>> Adding shared resources during page construction is very unusual.
>>>> Consider registering shared resources in
>>> Application.init(), or using
>>>> non-shared images. Refer to http://wicketstuff.org/wicket/images/
>>>>
>>>> On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F.
>>> <mi...@seznam.cz>  wrote:
>>>>> Hi folks,
>>>>>
>>>>> I have these classes:
>>>>>
>>>>> package com.myapp;
>>>>> public class Minerals extends WebPage{
>>>>>         public Minerals(){
>>>>>                 RepeatingView repeater = new
>>>> RepeatingView("repeater");
>>>>>                 //data from database - images and descriptions
>>>>>                 ArrayList dataFromDB = (new
>>> ImagesMinerals()).load();
>>>>>                 //descriptions
>>>>>                 ArrayList desc = new ArrayList();
>>>>>                 desc = (ArrayList) dataFromDB.get(0);
>>>>>                 //images
>>>>>                 ArrayList images = new ArrayList();
>>>>>                 images = (ArrayList) dataFromDB.get(1);
>>>>>                 int size = images.size();
>>>>>                 for(int i = 0; i<  size; i++){
>>>>>                         String repeaterID = repeater.newChildId();
>>>>>                         ImageRepeater repeaterChild = new
>>>>> ImageRepeater(repeaterID);
>>>>>                         //add description
>>>>>                         repeaterChild.add(new Label("description",
>>>>> (String) desc.get(i)));
>>>>>                         //add image
>>>>>                         DBImage image = new DBImage();
>>>>>                         image.setImageData((byte[]) images.get(i));
>>>>>                         //not caching on browser
>>>>>                         Double random = Math.random();
>>>>>                         //put shared resource (image) on clean path
>>>>>
>>>> Start.get().getSharedResources().add("image" +
>>>>> random.toString() + ".jpg", image);
>>>>>                         ResourceReference imageResource = new
>>>>> ResourceReference("image" + random.toString() + ".jpg");
>>>>>                         String url =
>>>>> RequestCycle.get().urlFor(imageResource).toString();
>>>>>                         //href in<a>  and src in<img>
>>>> should have same
>>>>> path because lightbox won't work...
>>>>>                         ExternalLink odkaz = new
>>>> ExternalLink("anchor",
>>>>> url);
>>>>>                         WebMarkupContainer imageSrcAttribute = new
>>>>> WebMarkupContainer("image");
>>>>>                         imageSrcAttribute.add(new
>>>>> AttributeModifier("src", new Model<String>(url)));
>>>>>                         odkaz.add(imageSrcAttribute);
>>>>>                         odkaz.add(new
>>>> SimpleAttributeModifier("title",
>>>>> (String) desc.get(i)));
>>>>>                         repeaterChild.add(odkaz);
>>>>>                         repeater.add(repeaterChild);
>>>>>                 }
>>>>>                 this.add(repeater);
>>>>>         }
>>>>> }
>>>>>
>>>>> package com.myapp;
>>>>> public class ImagesMinerals extends
>>>>> LoadableDetachableModel<ArrayList<byte[]>>{
>>>>>         @Override
>>>>>         protected ArrayList load(){
>>>>>                 DBGetImages databaseMinerals = new DBGetImages();
>>>>>                 ArrayList dataMineraly =
>>> databaseMinerals.getData();
>>>>>                 return dataMinerals;
>>>>>         }
>>>>> }
>>>>>
>>>>> My problem is that when i again and again click on page the
>>>> memory in
>>>>> tomcat is eaten and I end-up with Java heap space error. Doesn't
>>>>> matter if heap is 64MB or 1GB on start, after some clicks
>>> memory is
>>>>> eaten.
>>>>>
>>>>> Somethink wrong with my LDM?
>>>>>
>>>>> Miro
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>

RE: tomcat eats memory

Posted by "Miroslav F." <mi...@seznam.cz>.
With this I have problem that then I need to take url from Image component
and put it into Link component:
<a	href="#" <!-- <-this atribute --> wicket:id="anchor"
			rel="lightbox"
			title="">
				<img	style="border: 3px solid #DCD4A7;
padding: 1px 1px 1px 1px; width: 199px; height: 149px;" alt="" src="" <!--
<-and this atribute -->
						wicket:id="image">
		</a>
<!-- have to had the same url + .jpg at the end. Otherwise Lightbox won't
work -->

No problem make Image component as in example (my first attempt was same)
but not know how then take url from image component and put into Link
component.



> -----Original Message-----
> From: Dan Retzlaff [mailto:dretzlaff@gmail.com] 
> Sent: Friday, 05. August 2011 19:58
> To: users@wicket.apache.org
> Subject: Re: tomcat eats memory
> 
> It sounds like a shared resource is not the right solution 
> for your problem.
> Just throw a wicket:id on your Lightbox image tag and create 
> a Wicket Image like "image5" of the wicketstuff examples link I sent.
> 
> On Fri, Aug 5, 2011 at 10:46 AM, Miroslav F. <mi...@seznam.cz> wrote:
> 
> > Answer myself: should be solution before 
> > Start.get().getSharedResources().add("image" + random.toString() + 
> > ".jpg", image); do something like "unmount all previosly mounted 
> > images"?
> >
> > In Application.init() isn't possible to mount them - I don't know 
> > which page user click. In database is around 1.000 images and there 
> > are on around 100 pages (every page has around 10 images). 
> For me it 
> > looks crazy in Application.init() take all images from DB and mount 
> > them.
> >
> >
> > > -----Original Message-----
> > > From: Miroslav F. [mailto:mirfok@seznam.cz]
> > > Sent: Friday, 05. August 2011 18:54
> > > To: users@wicket.apache.org
> > > Subject: RE: tomcat eats memory
> > >
> > > Using non-shared images? My problem is that I need same 
> url for href 
> > > in <a> and for src in <img> for lightbox to work.
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Dan Retzlaff [mailto:dretzlaff@gmail.com]
> > > > Sent: Friday, 05. August 2011 18:45
> > > > To: users@wicket.apache.org
> > > > Subject: Re: tomcat eats memory
> > > >
> > > > This is your problem:
> > > >
> > > > Start.get().getSharedResources().add("image" +
> > > > > random.toString() + ".jpg", image);
> > > >
> > > >
> > > > Adding shared resources during page construction is 
> very unusual.
> > > > Consider registering shared resources in
> > > Application.init(), or using
> > > > non-shared images. Refer to 
> http://wicketstuff.org/wicket/images/
> > > >
> > > > On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F.
> > > <mi...@seznam.cz> wrote:
> > > >
> > > > > Hi folks,
> > > > >
> > > > > I have these classes:
> > > > >
> > > > > package com.myapp;
> > > > > public class Minerals extends WebPage{
> > > > >        public Minerals(){
> > > > >                RepeatingView repeater = new
> > > > RepeatingView("repeater");
> > > > >                //data from database - images and descriptions
> > > > >                ArrayList dataFromDB = (new
> > > ImagesMinerals()).load();
> > > > >                //descriptions
> > > > >                ArrayList desc = new ArrayList();
> > > > >                desc = (ArrayList) dataFromDB.get(0);
> > > > >                //images
> > > > >                ArrayList images = new ArrayList();
> > > > >                images = (ArrayList) dataFromDB.get(1);
> > > > >                int size = images.size();
> > > > >                for(int i = 0; i < size; i++){
> > > > >                        String repeaterID = 
> repeater.newChildId();
> > > > >                        ImageRepeater repeaterChild = new 
> > > > > ImageRepeater(repeaterID);
> > > > >                        //add description
> > > > >                        repeaterChild.add(new 
> > > > > Label("description",
> > > > > (String) desc.get(i)));
> > > > >                        //add image
> > > > >                        DBImage image = new DBImage();
> > > > >                        image.setImageData((byte[]) 
> images.get(i));
> > > > >                        //not caching on browser
> > > > >                        Double random = Math.random();
> > > > >                        //put shared resource (image) on clean 
> > > > > path
> > > > >
> > > > Start.get().getSharedResources().add("image" +
> > > > > random.toString() + ".jpg", image);
> > > > >                        ResourceReference imageResource = new 
> > > > > ResourceReference("image" + random.toString() + ".jpg");
> > > > >                        String url = 
> > > > > RequestCycle.get().urlFor(imageResource).toString();
> > > > >                        //href in <a> and src in <img>
> > > > should have same
> > > > > path because lightbox won't work...
> > > > >                        ExternalLink odkaz = new
> > > > ExternalLink("anchor",
> > > > > url);
> > > > >                        WebMarkupContainer imageSrcAttribute = 
> > > > > new WebMarkupContainer("image");
> > > > >                        imageSrcAttribute.add(new 
> > > > > AttributeModifier("src", new Model<String>(url)));
> > > > >                        odkaz.add(imageSrcAttribute);
> > > > >                        odkaz.add(new
> > > > SimpleAttributeModifier("title",
> > > > > (String) desc.get(i)));
> > > > >                        repeaterChild.add(odkaz);
> > > > >                        repeater.add(repeaterChild);
> > > > >                }
> > > > >                this.add(repeater);
> > > > >        }
> > > > > }
> > > > >
> > > > > package com.myapp;
> > > > > public class ImagesMinerals extends 
> > > > > LoadableDetachableModel<ArrayList<byte[]>>{
> > > > >        @Override
> > > > >        protected ArrayList load(){
> > > > >                DBGetImages databaseMinerals = new 
> DBGetImages();
> > > > >                ArrayList dataMineraly =
> > > databaseMinerals.getData();
> > > > >                return dataMinerals;
> > > > >        }
> > > > > }
> > > > >
> > > > > My problem is that when i again and again click on page the
> > > > memory in
> > > > > tomcat is eaten and I end-up with Java heap space 
> error. Doesn't 
> > > > > matter if heap is 64MB or 1GB on start, after some clicks
> > > memory is
> > > > > eaten.
> > > > >
> > > > > Somethink wrong with my LDM?
> > > > >
> > > > > Miro
> > > > >
> > > > >
> > > > >
> > > >
> > > 
> --------------------------------------------------------------------
> > > -
> > > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > > >
> > > > >
> > > >
> > >
> > >
> > > 
> --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: tomcat eats memory

Posted by Dan Retzlaff <dr...@gmail.com>.
It sounds like a shared resource is not the right solution for your problem.
Just throw a wicket:id on your Lightbox image tag and create a Wicket Image
like "image5" of the wicketstuff examples link I sent.

On Fri, Aug 5, 2011 at 10:46 AM, Miroslav F. <mi...@seznam.cz> wrote:

> Answer myself: should be solution before
> Start.get().getSharedResources().add("image" + random.toString() + ".jpg",
> image);
> do something like "unmount all previosly mounted images"?
>
> In Application.init() isn't possible to mount them - I don't know which
> page
> user click. In database is around 1.000 images
> and there are on around 100 pages (every page has around 10 images). For me
> it looks crazy in Application.init() take all images
> from DB and mount them.
>
>
> > -----Original Message-----
> > From: Miroslav F. [mailto:mirfok@seznam.cz]
> > Sent: Friday, 05. August 2011 18:54
> > To: users@wicket.apache.org
> > Subject: RE: tomcat eats memory
> >
> > Using non-shared images? My problem is that I need same url
> > for href in <a> and for src in <img> for lightbox to work.
> >
> >
> >
> > > -----Original Message-----
> > > From: Dan Retzlaff [mailto:dretzlaff@gmail.com]
> > > Sent: Friday, 05. August 2011 18:45
> > > To: users@wicket.apache.org
> > > Subject: Re: tomcat eats memory
> > >
> > > This is your problem:
> > >
> > > Start.get().getSharedResources().add("image" +
> > > > random.toString() + ".jpg", image);
> > >
> > >
> > > Adding shared resources during page construction is very unusual.
> > > Consider registering shared resources in
> > Application.init(), or using
> > > non-shared images. Refer to http://wicketstuff.org/wicket/images/
> > >
> > > On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F.
> > <mi...@seznam.cz> wrote:
> > >
> > > > Hi folks,
> > > >
> > > > I have these classes:
> > > >
> > > > package com.myapp;
> > > > public class Minerals extends WebPage{
> > > >        public Minerals(){
> > > >                RepeatingView repeater = new
> > > RepeatingView("repeater");
> > > >                //data from database - images and descriptions
> > > >                ArrayList dataFromDB = (new
> > ImagesMinerals()).load();
> > > >                //descriptions
> > > >                ArrayList desc = new ArrayList();
> > > >                desc = (ArrayList) dataFromDB.get(0);
> > > >                //images
> > > >                ArrayList images = new ArrayList();
> > > >                images = (ArrayList) dataFromDB.get(1);
> > > >                int size = images.size();
> > > >                for(int i = 0; i < size; i++){
> > > >                        String repeaterID = repeater.newChildId();
> > > >                        ImageRepeater repeaterChild = new
> > > > ImageRepeater(repeaterID);
> > > >                        //add description
> > > >                        repeaterChild.add(new Label("description",
> > > > (String) desc.get(i)));
> > > >                        //add image
> > > >                        DBImage image = new DBImage();
> > > >                        image.setImageData((byte[]) images.get(i));
> > > >                        //not caching on browser
> > > >                        Double random = Math.random();
> > > >                        //put shared resource (image) on clean path
> > > >
> > > Start.get().getSharedResources().add("image" +
> > > > random.toString() + ".jpg", image);
> > > >                        ResourceReference imageResource = new
> > > > ResourceReference("image" + random.toString() + ".jpg");
> > > >                        String url =
> > > > RequestCycle.get().urlFor(imageResource).toString();
> > > >                        //href in <a> and src in <img>
> > > should have same
> > > > path because lightbox won't work...
> > > >                        ExternalLink odkaz = new
> > > ExternalLink("anchor",
> > > > url);
> > > >                        WebMarkupContainer imageSrcAttribute = new
> > > > WebMarkupContainer("image");
> > > >                        imageSrcAttribute.add(new
> > > > AttributeModifier("src", new Model<String>(url)));
> > > >                        odkaz.add(imageSrcAttribute);
> > > >                        odkaz.add(new
> > > SimpleAttributeModifier("title",
> > > > (String) desc.get(i)));
> > > >                        repeaterChild.add(odkaz);
> > > >                        repeater.add(repeaterChild);
> > > >                }
> > > >                this.add(repeater);
> > > >        }
> > > > }
> > > >
> > > > package com.myapp;
> > > > public class ImagesMinerals extends
> > > > LoadableDetachableModel<ArrayList<byte[]>>{
> > > >        @Override
> > > >        protected ArrayList load(){
> > > >                DBGetImages databaseMinerals = new DBGetImages();
> > > >                ArrayList dataMineraly =
> > databaseMinerals.getData();
> > > >                return dataMinerals;
> > > >        }
> > > > }
> > > >
> > > > My problem is that when i again and again click on page the
> > > memory in
> > > > tomcat is eaten and I end-up with Java heap space error. Doesn't
> > > > matter if heap is 64MB or 1GB on start, after some clicks
> > memory is
> > > > eaten.
> > > >
> > > > Somethink wrong with my LDM?
> > > >
> > > > Miro
> > > >
> > > >
> > > >
> > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > > For additional commands, e-mail: users-help@wicket.apache.org
> > > >
> > > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: tomcat eats memory

Posted by "Miroslav F." <mi...@seznam.cz>.
Answer myself: should be solution before
Start.get().getSharedResources().add("image" + random.toString() + ".jpg",
image);
do something like "unmount all previosly mounted images"?

In Application.init() isn't possible to mount them - I don't know which page
user click. In database is around 1.000 images
and there are on around 100 pages (every page has around 10 images). For me
it looks crazy in Application.init() take all images
from DB and mount them.


> -----Original Message-----
> From: Miroslav F. [mailto:mirfok@seznam.cz] 
> Sent: Friday, 05. August 2011 18:54
> To: users@wicket.apache.org
> Subject: RE: tomcat eats memory
> 
> Using non-shared images? My problem is that I need same url 
> for href in <a> and for src in <img> for lightbox to work.
> 
> 
> 
> > -----Original Message-----
> > From: Dan Retzlaff [mailto:dretzlaff@gmail.com]
> > Sent: Friday, 05. August 2011 18:45
> > To: users@wicket.apache.org
> > Subject: Re: tomcat eats memory
> > 
> > This is your problem:
> > 
> > Start.get().getSharedResources().add("image" +
> > > random.toString() + ".jpg", image);
> > 
> > 
> > Adding shared resources during page construction is very unusual. 
> > Consider registering shared resources in 
> Application.init(), or using 
> > non-shared images. Refer to http://wicketstuff.org/wicket/images/
> > 
> > On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F. 
> <mi...@seznam.cz> wrote:
> > 
> > > Hi folks,
> > >
> > > I have these classes:
> > >
> > > package com.myapp;
> > > public class Minerals extends WebPage{
> > >        public Minerals(){
> > >                RepeatingView repeater = new
> > RepeatingView("repeater");
> > >                //data from database - images and descriptions
> > >                ArrayList dataFromDB = (new 
> ImagesMinerals()).load();
> > >                //descriptions
> > >                ArrayList desc = new ArrayList();
> > >                desc = (ArrayList) dataFromDB.get(0);
> > >                //images
> > >                ArrayList images = new ArrayList();
> > >                images = (ArrayList) dataFromDB.get(1);
> > >                int size = images.size();
> > >                for(int i = 0; i < size; i++){
> > >                        String repeaterID = repeater.newChildId();
> > >                        ImageRepeater repeaterChild = new 
> > > ImageRepeater(repeaterID);
> > >                        //add description
> > >                        repeaterChild.add(new Label("description",
> > > (String) desc.get(i)));
> > >                        //add image
> > >                        DBImage image = new DBImage();
> > >                        image.setImageData((byte[]) images.get(i));
> > >                        //not caching on browser
> > >                        Double random = Math.random();
> > >                        //put shared resource (image) on clean path
> > >                        
> > Start.get().getSharedResources().add("image" +
> > > random.toString() + ".jpg", image);
> > >                        ResourceReference imageResource = new 
> > > ResourceReference("image" + random.toString() + ".jpg");
> > >                        String url =
> > > RequestCycle.get().urlFor(imageResource).toString();
> > >                        //href in <a> and src in <img>
> > should have same
> > > path because lightbox won't work...
> > >                        ExternalLink odkaz = new
> > ExternalLink("anchor",
> > > url);
> > >                        WebMarkupContainer imageSrcAttribute = new 
> > > WebMarkupContainer("image");
> > >                        imageSrcAttribute.add(new 
> > > AttributeModifier("src", new Model<String>(url)));
> > >                        odkaz.add(imageSrcAttribute);
> > >                        odkaz.add(new
> > SimpleAttributeModifier("title",
> > > (String) desc.get(i)));
> > >                        repeaterChild.add(odkaz);
> > >                        repeater.add(repeaterChild);
> > >                }
> > >                this.add(repeater);
> > >        }
> > > }
> > >
> > > package com.myapp;
> > > public class ImagesMinerals extends
> > > LoadableDetachableModel<ArrayList<byte[]>>{
> > >        @Override
> > >        protected ArrayList load(){
> > >                DBGetImages databaseMinerals = new DBGetImages();
> > >                ArrayList dataMineraly = 
> databaseMinerals.getData();
> > >                return dataMinerals;
> > >        }
> > > }
> > >
> > > My problem is that when i again and again click on page the
> > memory in
> > > tomcat is eaten and I end-up with Java heap space error. Doesn't 
> > > matter if heap is 64MB or 1GB on start, after some clicks 
> memory is 
> > > eaten.
> > >
> > > Somethink wrong with my LDM?
> > >
> > > Miro
> > >
> > >
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: tomcat eats memory

Posted by "Miroslav F." <mi...@seznam.cz>.
Using non-shared images? My problem is that I need same url for href in <a>
and for
src in <img> for lightbox to work.



> -----Original Message-----
> From: Dan Retzlaff [mailto:dretzlaff@gmail.com] 
> Sent: Friday, 05. August 2011 18:45
> To: users@wicket.apache.org
> Subject: Re: tomcat eats memory
> 
> This is your problem:
> 
> Start.get().getSharedResources().add("image" +
> > random.toString() + ".jpg", image);
> 
> 
> Adding shared resources during page construction is very 
> unusual. Consider registering shared resources in 
> Application.init(), or using non-shared images. Refer to 
> http://wicketstuff.org/wicket/images/
> 
> On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F. <mi...@seznam.cz> wrote:
> 
> > Hi folks,
> >
> > I have these classes:
> >
> > package com.myapp;
> > public class Minerals extends WebPage{
> >        public Minerals(){
> >                RepeatingView repeater = new 
> RepeatingView("repeater");
> >                //data from database - images and descriptions
> >                ArrayList dataFromDB = (new ImagesMinerals()).load();
> >                //descriptions
> >                ArrayList desc = new ArrayList();
> >                desc = (ArrayList) dataFromDB.get(0);
> >                //images
> >                ArrayList images = new ArrayList();
> >                images = (ArrayList) dataFromDB.get(1);
> >                int size = images.size();
> >                for(int i = 0; i < size; i++){
> >                        String repeaterID = repeater.newChildId();
> >                        ImageRepeater repeaterChild = new 
> > ImageRepeater(repeaterID);
> >                        //add description
> >                        repeaterChild.add(new Label("description", 
> > (String) desc.get(i)));
> >                        //add image
> >                        DBImage image = new DBImage();
> >                        image.setImageData((byte[]) images.get(i));
> >                        //not caching on browser
> >                        Double random = Math.random();
> >                        //put shared resource (image) on clean path
> >                        
> Start.get().getSharedResources().add("image" +
> > random.toString() + ".jpg", image);
> >                        ResourceReference imageResource = new 
> > ResourceReference("image" + random.toString() + ".jpg");
> >                        String url =
> > RequestCycle.get().urlFor(imageResource).toString();
> >                        //href in <a> and src in <img> 
> should have same 
> > path because lightbox won't work...
> >                        ExternalLink odkaz = new 
> ExternalLink("anchor", 
> > url);
> >                        WebMarkupContainer imageSrcAttribute = new 
> > WebMarkupContainer("image");
> >                        imageSrcAttribute.add(new 
> > AttributeModifier("src", new Model<String>(url)));
> >                        odkaz.add(imageSrcAttribute);
> >                        odkaz.add(new 
> SimpleAttributeModifier("title",
> > (String) desc.get(i)));
> >                        repeaterChild.add(odkaz);
> >                        repeater.add(repeaterChild);
> >                }
> >                this.add(repeater);
> >        }
> > }
> >
> > package com.myapp;
> > public class ImagesMinerals extends
> > LoadableDetachableModel<ArrayList<byte[]>>{
> >        @Override
> >        protected ArrayList load(){
> >                DBGetImages databaseMinerals = new DBGetImages();
> >                ArrayList dataMineraly = databaseMinerals.getData();
> >                return dataMinerals;
> >        }
> > }
> >
> > My problem is that when i again and again click on page the 
> memory in 
> > tomcat is eaten and I end-up with Java heap space error. Doesn't 
> > matter if heap is 64MB or 1GB on start, after some clicks memory is 
> > eaten.
> >
> > Somethink wrong with my LDM?
> >
> > Miro
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: tomcat eats memory

Posted by Dan Retzlaff <dr...@gmail.com>.
This is your problem:

Start.get().getSharedResources().add("image" +
> random.toString() + ".jpg", image);


Adding shared resources during page construction is very unusual. Consider
registering shared resources in Application.init(), or using non-shared
images. Refer to http://wicketstuff.org/wicket/images/

On Fri, Aug 5, 2011 at 9:20 AM, Miroslav F. <mi...@seznam.cz> wrote:

> Hi folks,
>
> I have these classes:
>
> package com.myapp;
> public class Minerals extends WebPage{
>        public Minerals(){
>                RepeatingView repeater = new RepeatingView("repeater");
>                //data from database - images and descriptions
>                ArrayList dataFromDB = (new ImagesMinerals()).load();
>                //descriptions
>                ArrayList desc = new ArrayList();
>                desc = (ArrayList) dataFromDB.get(0);
>                //images
>                ArrayList images = new ArrayList();
>                images = (ArrayList) dataFromDB.get(1);
>                int size = images.size();
>                for(int i = 0; i < size; i++){
>                        String repeaterID = repeater.newChildId();
>                        ImageRepeater repeaterChild = new
> ImageRepeater(repeaterID);
>                        //add description
>                        repeaterChild.add(new Label("description", (String)
> desc.get(i)));
>                        //add image
>                        DBImage image = new DBImage();
>                        image.setImageData((byte[]) images.get(i));
>                        //not caching on browser
>                        Double random = Math.random();
>                        //put shared resource (image) on clean path
>                        Start.get().getSharedResources().add("image" +
> random.toString() + ".jpg", image);
>                        ResourceReference imageResource = new
> ResourceReference("image" + random.toString() + ".jpg");
>                        String url =
> RequestCycle.get().urlFor(imageResource).toString();
>                        //href in <a> and src in <img> should have same path
> because lightbox won't work...
>                        ExternalLink odkaz = new ExternalLink("anchor",
> url);
>                        WebMarkupContainer imageSrcAttribute = new
> WebMarkupContainer("image");
>                        imageSrcAttribute.add(new AttributeModifier("src",
> new Model<String>(url)));
>                        odkaz.add(imageSrcAttribute);
>                        odkaz.add(new SimpleAttributeModifier("title",
> (String) desc.get(i)));
>                        repeaterChild.add(odkaz);
>                        repeater.add(repeaterChild);
>                }
>                this.add(repeater);
>        }
> }
>
> package com.myapp;
> public class ImagesMinerals extends
> LoadableDetachableModel<ArrayList<byte[]>>{
>        @Override
>        protected ArrayList load(){
>                DBGetImages databaseMinerals = new DBGetImages();
>                ArrayList dataMineraly = databaseMinerals.getData();
>                return dataMinerals;
>        }
> }
>
> My problem is that when i again and again click on page the memory in
> tomcat
> is eaten and I end-up with
> Java heap space error. Doesn't matter if heap is 64MB or 1GB on start,
> after
> some clicks memory is eaten.
>
> Somethink wrong with my LDM?
>
> Miro
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>