Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Applet Memory limit (Read 4514 times)
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Applet Memory limit
Jul 18th, 2007 at 1:31am
Print Post  
Hi,

The SUN JRE forces an upper limit on the memory usage by an applet (I think 64 MB). So, the number of mindfusion items that can be created on the applet must be limited. Do you guys have a way of increasing this number without inconveniencing the end-user (asking him to use the -Xmx option in the Java control panel - which is again a painful feature, because we can never be sure if the same value will work on all the machines)?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Applet Memory limit
Reply #1 - Jul 18th, 2007 at 7:20am
Print Post  
Hi,

In JRE 1.5 the default max memory for applets is 96MB. You could check how much memory your diagram requires by adding the following code to the end of FlowChart.paintComponent():

Code
Select All
// display available memory
double mm = Constants.getMillimeter(measureUnit);
float fontSize = (float) (4 * mm);
Font font = XmlReader.createFont("Arial", fontSize, false, false);
graphics.setFont(font);
graphics.setColor(Color.red);
graphics.drawString("max mem: " + Long.toString(Runtime.getRuntime().maxMemory() / 1024),
	(float)(docBounds.getX() + mm), (float)(docBounds.getY() + font.getSize() + 5*mm));
graphics.drawString("allocated: " + Long.toString(Runtime.getRuntime().totalMemory() / 1024),
	(float)(docBounds.getX() + mm), (float)(docBounds.getY() + font.getSize() + 10*mm));
 



The allocated memory is the OS memory currently allocated to the JVM. Much of it might be still available for new Java objects, before JVM asks the OS for more memory.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Applet Memory limit
Reply #2 - Aug 6th, 2007 at 1:22am
Print Post  
Hi Stoyan,

I have tested the application adding items to the canvas in a loop.

I have observed that around 10,000 objects are handled alright. Over 10,000 objects, the page doesn't load, It stays with the Java Loading icon and a CPU utilization of 100%

Now, I could have some boxes that need the name to be displayed on the outside. The Developer Guide suggests that I use another box to represent the text, with the box set to transparent.

If I need 10,000 of such boxes on my canvas, I am effectively creating 20,000 boxes (one for the actual box and one for the name-box). The web page does not load in this case.

I have two questions now.

1. Is there some sort of lightweight box that can be used just to display the name?

2. Is there some way I can create 10,000 such boxes in the web page?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Applet Memory limit
Reply #3 - Aug 6th, 2007 at 6:54am
Print Post  
Hi Praveen,

Instead of attaching an additional box to display the text, define a custom shape whose text area is outside the shape outlines, i.e. not in the [0-100, 0-100] range.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Applet Memory limit
Reply #4 - Aug 6th, 2007 at 7:06am
Print Post  
Hi Stoyan,

I was also looking at the name to be draggable around on the flowchart. I am guessing this can only happen if it is another box?

Also, I noticed that the memory maxes out when the iexplore process is using around 145-149 MB and does not get any more memory allocated. With 15K objects (regular, without the extra attached box) added to the flowchart, the canvas doesn't come up. I could then increase it using the -Xmx option.
Is it the only option to increase the memory limit? Or can it be programmatically set so I can show more boxes?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Applet Memory limit
Reply #5 - Aug 6th, 2007 at 12:14pm
Print Post  
Hi Praveen,

You might use custom drawing to draw the text at a position you'd like. Implement some label-editing mode that will display an auxiliary label box that users can move around. Exit the edit mode when the auxiliary box is deselected, and update the coordinates of the label that has been moved. That will let you avoid using more boxes than necessary.

I don't think there is any way to increase the memory limit programmatically. You might use the Java memory functions to detect when the memory is near the limit, and if so either unload some part of the diagram, or display instructions to users how to increase the memory limit themselves.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint