Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

Mohammad Farhat

Ranch Hand
+ Follow
since Nov 17, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mohammad Farhat

Hey guys,
i am using an applet to display images (i would of placed this question under applet, but it is memory consumption)
So the issue is that i have this image, which is stored inside an Image instance. When i am trying to render on a canvas, the memory consumption would double, and then, i end up having two different instances of the pixels of the image (saw that using a memory profiler - one of them is img.source.pixels, the other is img.imagerep.biRaster.data). This is critical since some images come in 20MB pixel size, so now i am ending up with 40MB per image (double size)
the code i am using to draw the image is using double buffering relying on an Graphics object (offg) which references the image through the
offg = offImage.getGraphics();
and then drawing using the drawImage to draw the image instance (parent.imageDataArray[imgNo].getCurrentImage())
offg.drawImage(parent.imageDataArray[imgNo].getCurrentImage(),
(int) x[imgNo],
(int) y[imgNo],
(int) w[imgNo],
(int) h[imgNo],
this);

Even without double buffering, i still get the double memory consumption. Is the drawImage making another copy of the image in memory, causing therefore the duplication of memory usage. And is there a way to draw the image while avoiding this?
Thanks a lot guys
Best,
Mohammad
15 years ago
Yeah
definitely...my main problem is with this parameter (-Xmx), when setting to values larger than 300m on my pc (1GB RAM), IE would not start, and i get a jre runtime error. This does not occur with firefox unless i set really high values (higher than 650m)
in other cases (pcs with 512 MB RAM), this problem occurs with -Xmx260m, and even with less values sometimes
Thanks,
Mohammad
15 years ago
Yeah
definitely...my main problem is with this parameter (-Xmx), when setting to values larger than 300m on my pc (1GB RAM), IE would not start, and i get a jre runtime error. This does not occur with firefox
in other cases (pcs with 512 MB RAM), this problem occurs with -Xmx260m, and even with less values sometimes
Thanks,
Mohammad
15 years ago
Ulf,
thanks for your reply
i am definitely using java virtual machine, not microsoft's virtual machine.
the only thing that occurred to me to having multiple virtual machines, is that each one of them would be able to take up to a certain limit of memory, and i can therefore spread the load across them.
i am trying to improve the memory performance of my applet, but it is minimal so far, and i really need to get over this barrier of IE-JVM interaction (which is not existing under firefox-JVM)
it would be wondeful if someone comes up with some solution for this
waiting your suggestions guys
Best,
Mohammad
15 years ago
Hey guys,
long time not posted here
i have an applet which handles displaying images, now these images are sometimes large in size. i have been increasing the maximum heap size for the applet (setting -Xmx260m) to handle up to this amount of memory, this works fine under firefox. In firefox case, i can go up to 650MB without any problems. Under IE, the problem i am facing is when i try to increase the size beyond 300MB (for my 1GB machine), and under other machines, even above 150MB would cause problems (the problem being jre not being able to load). I understand this is caused by IE-java issue not allowing large amounts of contiguous memory to be assigned to jvm.
Any suggestions to solve this issue? opening multiple jvms for example? i do need to support large amounts of memory (why should i have a limitation in IE case which is much smaller than firefox) ..
Thanks a lot guys
Best,
Mohammad
15 years ago
Hey guys,
how is it going?
i have a java applet loaded inside a browser. The browser controls many of the functionalities of the applet, and can make modifications to it. That's not the issue...what i am currently doing is creating a button that does a clone of the current window, but the problem is that a fresh new copy of the applet is created inside the new browser with the default settings. What i need to do is to be able to clone the window with the current settings, i.e. if i changed some mode in the initial applet, i want that reflected in the new loaded applet. Any means to do that without the need to save all the current changes into some text file and have the new applet load from that file? this is a troublesome and heavy approach since there might be too many parameters i need to save. So if you know of any means to replicate the currenty opened window into a new one with the settings modified according to the old one, please advice...
Thanks a lot guys..
Best,
Mohammad
16 years ago
Dear Anil,
you can use JSObject to call javascript, but as far as i am concerned, this would not work under firefox. What you can do is use something like
getAppletContext().showDocument(new URL("javascript:setPropertyBoolean(\"submit\",\"disabled\", false);"));
this will allow you to call any javascript function (whether it is built in or you wrote it) inside the form containing the applet. I would suggest using this script for firefox and the JSObject for IE and netscape.
As for submitting the form, surely you can do that...
simply call the document.formname.submit() javascript function, and it would do that for you
ex: getAppletContext().showDocument(new URL("javascript ocument.formname.submit();"));
Best,
Mohammad
16 years ago
Well, if you were unable to find the file (or even the directory) i pointed out, then you will need to change the appropriate java.policy file of your current jre installation (this can be found under jre\lib\security\java.policy). The file i pointed out with the c:\documents and settings\<USERNAME>... is the default one for ll jre used in the system.
Ofcourse
As for as to what to modify the java.policy file to, i have really tried many things before, and the only thing that worked for me was setting what i mentioned eariler, "grant { permission java.security.AllPermission; };"
this would allow the applet to have full control over you system.
Best,
Mohammad
16 years ago
Hey man,
so you are using an applet viewer? or an html page?
if you can use an html page, this can be easily done using javascript..
if you need the script, i can provide it
Best,
Mohammad
16 years ago
Hey Amir,
why don't you compile your applet with jdk 1.4, this way you will guarantee that it will work with both 1.4 and 1.5
in case you get errors in compilation, you will need to find workarounds (these maybe the same ones causing jre1.4 not to run your applet)
Best,
Mohammad
16 years ago
Veronica,
you can have the applet easily talk to the container page, and vice versa.
In order to do that, you need first to include the following library into your applet:
import netscape.javascript.*;
this library is available in your default jre
it allows you to talk to use javascript to talk to your html container page
next, you will need to add this code:
try
{
JSObject win = (JSObject) JSObject.getWindow(this);
}
catch (Exception e)
{
System.out.println("an error occured");
}
this will allow you to use the win object to call any javascript code to the container page.
and then call the win.eval function with the javascript being the parameter.
For example, If you need to access some tag in your html page, inside the win.eval call, you can use:
"document.getElementById(\"password\").disabled=false" inside the win.eval function (could not type the whole statement because javaranch assumed it was a hack attempt )
this will set a field called password to enabled
Best,
Mohammad
16 years ago
Well Andrew,
you need to have the applet signed, and you probably would need to set appropriate permissions (security permissions) on the client's machine in order to be able to have complete access to the file system of the client.
As far as signing the applet, this is a "somewhat" simple task that you can look for online (many links exist).
As for setting security permissions, you can do that by modifying the security file located at C:\Documents and Settings\<USERNAME>\Application Data\sun\Java\Deployment\security\java.policy to only contain:
grant { permission java.security.AllPermission; };
this will give complete access to applets
Best,
Mohammad
16 years ago
Alan,
can we get more information about which jdk you are using to develop your applet?
i would suggest trying to run your applet with jres older than 1.5.0_06 (it might have flaws you know, i had problems with this particular jre myself)
that's one thing, another thing you might consider is to try to build a very simple applet (maybe some code is causing the crash, but really that is unlikely) for example that only displays some output statement, isolating the classes is a good idea always so that you know what is the real cause of crash, is it compatibility issue ...
Maybe it's a display issue, since if i noticed correctly, it involves AWT...
This is what i can think of at the moment...
Best,
Mohammad
16 years ago
Hey guys,
i am having some problems with tomcat; when i start tomcat, it starts correctly, and i can access my website and all. But the problem is with shutting it down. If i shutdown tomcat through ./shutdown.sh, it does shutdown (i can no longer access my files), but the tomcat process is still running (if i try the same thing again, it gives me
Catalina.stop: java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method))
Meanwhile, if i try to restart directly /etc/rc.d/tomcat5 restart(without shutting down before), it hangs while doing this (eventhough again i can no longer access my website)
i will need to manually kill the process, and then run /etc/rc.d/tomcat5 restart which will start tomcat again (or use ./startup.sh)
Anyone has any idea?
thanks a lot guys,
Best,
Mohammad
16 years ago
Hey guys,
i have a signed applet. When i load the applet using a browser that is lacking some files, a security warning would normally show to ask the user to confirm his trust for the applet.
All is fine so far, but the problem is that sometimes the warning shows behind the browser, especially in cases where the user clicks on the link and moves to another window, this will make it very hard for the user to re-focus this warning message auto-generated by signed applets
Any ideas ?
thanks a bunch
Mohammad
16 years ago