But my complaint is that the GUI window shows up too slow, and when I check
the task manager, the memory usage keeps increasing slowly, and once it gets to
certain point it stops increasing and showing the GUI window that I made.
Obviously, I think it takes too much time, but I wonder the some preparation
step to launch the GUI window usually takes such a bit of time.
Any comments would be appreciated.
--
Isn't 30 secs a lot, and enough time for users being curious if the program is really running or not ? I often had to open the task manager to see what's going on. Maybe, I am too impatient.
And, I am wondering, if there is anyway for me to open up an image window real quick when I execute the program, and later on my main GUI window comes up, much like executing Matlab ?
--
I was wondering the same things!
I have put a trace at the beginning of my executable gui. After clicking the exe, it takes 30 seconds to appear. And the worst part is that nothing shows up during this process. Is there any way to decrease this time? I would also like to make a splash screen which appears as soon as executing the program if possible. Any suggestions?
Beside the very first time where the program is lauched: most of my compiled applications take:
1) Console Black windows appears < 100 ms
2) Some message starts to appears on ~ +1 sec
3) A main gui window appears ~+1 sec
I could show another textbox between 2) and 3), but why bother for 1sec?
The time I observe is no where close to 30 seconds.
Bruno
What about that first time? After you restarted your computer, if you execute the program before even opening the matlab, how long does it take the message to appear?
Less than 3 seconds.
Opening Matlab has nothing to do with execution, since the application supposes to work on the computer without Matlab. But "the first time"I meant the very first time a newly compiled program is launched, where it needs to unpacked the files and store it somewhere. All successive runs takes 3 seconds - regardless whereas the computer is just restarted or not and Matlab is opened or not.
Bruno
fprintf(1, 'Now opening mat file (%s) to initialize variables...\n',
fullMatFileName);
So put a bunch of stuff in there to keep the user entertained while it
launches.
It cant be, shouldnt be! Even the following simplest gui takes 20 seconds to display 'started' when executed for the first time after a restart. Once it starts, speed is pretty much the same for rest (with the case running through Matlab). But if I try again before restarting the computer it takes only 1 or 2 seconds to display 'started'. Unlike yours however, when i restart the computer and try again, i have to wait 20 seconds again! And i must say, my processor is i7..
By the way, i am creating the exe file with deploytool (in 2011a) with default settings..
tic,disp('started')
model=javax.swing.table.DefaultTableModel(num2cell(reshape(magic(10),[],2)),{'a','b'});
table=javax.swing.JTable(model);
sorter=javax.swing.table.TableRowSorter(model);
table.setRowSorter(sorter);
pane=javax.swing.JScrollPane(table);
frame=javax.swing.JFrame('');
frame.add(pane,java.awt.BorderLayout.CENTER);
frame.setSize(300,250);
frame.setVisible(true);
toc,disp('ended')
and define MCR_CACHE_ROOT environment variable so that the ctf file does extract the *_mcr at the folder where it is freed from automatically cleaning every time the computer reboots.
Bruno
This is a known issue with Matlab-compiled applications. In R2011b this problem is supposed to be reduced. But the core issue of having to unpack and load the MCR the first time it is used after a computer restart remains painful. In some cases I observed start-up times of up to a minute (obviously this depends on the specific hardware and CPU load).
The work-around that I have successfully used is to create a small wrapper application that simply displays a static "Please wait... Loading XYZ..." splash image (with a generic configuration of the image, size, etc.), then launches the main (compiled) application, and finally deletes the splash image when it detects that the main application has actually started. This gives the user an immediate feedback that the application is loading and this seems to resolve the issue. Anyone wishing to have this wrapper application, please contact me offline (altmany at gmail dot com).
Yair Altman
http://UndocumentedMatlab.com
Bruno, thank you! It sounds like that might be the problem. I have no clue about what i should do but i will study on it. I actually hope to get a result..
One more thing that i forgot to mention; the code i gave above creates a java frame and when i compile it, it doesnt work like a figure window. After appearing on screen it suddenly disappears and my application terminates (i also checked from task manager). I know that using a Matlab figure instead of a java frame is a solution but is it possible to use a java frame with a reasonable way? (using a pause shouldnt be one for example..)
---------------------------------------------------------------------
How are you launching it? Are you double-clicking on the icon in
Windows Explorer (My Computer)? Yes if it bombs it will barf a bunch
of stuff to the console window and then immediately close down the
console window. You need to run it from the command line or MATLAB in
order to have all the stuff it barfed up remain for you to inspect.
Here, try this:
Take these lines and save them to a file and call the file
RunDOSPromptHere.reg:
REGEDIT4
[HKEY_CLASSES_ROOT\Directory\Shell\DosPrompt]
@="Run MS-DOS Prompt here"
[HKEY_CLASSES_ROOT\Directory\Shell\DosPrompt\Command]
@="Cmd /k CD \"%L\" "
Now double click that file and say yes when it asks you for permission
to change the registry. What this will do is give you a new context
menu when you right click on a folder in Windows Explorer. You can
browse to any folder (such as the one where your exe lives) and then
right click and select "Run MS-DOC Prompt here" from the pop-up
context menu. It will immediately give you a console window with that
folder as the current directory. Basically it's the same as doing
Start/Run/cmd and then typing cd "c:\whatever\blahblahblah\yadayada"
Now, once you're in that folder, type the name of your executable and
it will run. BUT when it barfs and exits, all the stuff you printed
out plus all the error messages will remain in the console window for
you to inspect. You can do this on your target computer.
Have you verified that the executable works on your development
machine? You can do that by cd'ing to the folder where you told it to
put the exe. Then, in the MATLAB command window type ! (exclamation
mark) followed immediately (no space) with the name of your
executable. If it crashes also on your computer then that gives you
something to track down easier than deploying and trying to debug on
the target computer. The crash info will appear, and remain, in the
MATLAB command window.
Finally since you paid $5000 for the compiler, the Mathworks is pretty
helpful in helping you. I've had them track down some pretty esoteric
issues with compiled programs before. So if the entries in the FAQ
have all been tried and all failed, give the Mathworks tech support a
try - might as well get some support for your $5k.
Good luck,
ImageAnalyst
Can you use waitfor in one of the java objects? Such as
waitfor(frame, 'Visible','off')
Bruno
I didnt even try the waitfor because i had assumed that it needed a valid matlab handle something like javacompenent gives. It turns out that java components are also used with waitfor. But i am not sure exactly what 'waitfor' actually waits for; because when i close the java frame it still waits :)
Then i tried something else, i changed the closing callback as follows;
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
Guess what, when i close the frame now it also closes Matlab :) But surprisingly it worked for standalone. Program is terminated only when i close the window. I think using with 'isdeployed' might be a solution..
@Bruno, nothing changed unfortunately.
I have compiled my application with -C option and ctf files were extracted at the same folder with my executable file. However it still waits a very long time when the first time executed after restarting the computer. Everything is same with the case that ctf is embedded in exe file except some weird files in ctf folder. What is wrong here?
I don't know, it might be many reasons: your exe load some DLL, some anti-virus kicks in, etc. Contact TMW customer support if you think it's abnormal and the issue is not related to how your computer is setup.
Bruno
Hi Yair
I am very interested to get a copy of your small wrapper application. I have a large GUI that takes some time to start up especially first time when the MCR also need to be started. Therefore it could be very nice to get a copy of your small wrapper application that when I click the exe file it first run the small wrapper application and next the matlab code. When it then open the GUI window it exit the small wrapper application.
Best Regards
Robin