[Q]Could you help me to optimize the program?

Skrobel

Member
Licensed User
Hello again,

I would like to refer to the program you already helped me with, when it was in early stage. Now I learned a bit more about B4PPC and managed to make the app more and more usable. I even was "brave" enough to put the first version on xda-devs.

However I want to develop the app much further but I faced many problems concerning performance and memory. Some of the information I could found around here, some of them I tested with "trial&fail" method but still I want to ask you guys about some issues which blocked my entire progress:

The basic function of this program is to show a form filled with links to different functions (like new e-mail, new text message, toggle BT and WiFi etc.).

First version was started "on demand" and it worked fine. But it took 4-5 seconds for the frmMain to show. I reproduced all the images, quit from using imagelist for images that are not necessary every time the app starts, also merged the texts into background to be able to delete any unnecessary control from the form. Now the starting time is a bit betted but it's still too long for my consideration.

Then I started to develop the app in such way that it is run in "hidden" mode every system startup (by calling the ActionScreen.exe with "quiet" argument). I faced many problems but I managed to solve them with precious help of this forum. The problems I still have are:

1. The only way to actually load all the elements (images, controls) into memory is to show the form. Otherwise when I trigger the "ShowHomeScreen" before I show frmMain, the app doesn't run at all. I think it closes instantly. So whenever it's called for the second time it still needs 3-4 seconds.
So at startup I must actually show the app at least for 10 ms and then trigger the "ShowTodayScreen" procedure to hide it. And during system startup any graphics I'll try to show appear incomplete and for long time (until Sense interface shows). For that reason I put "Sleep(25000)" at the first If to make the form show as late as possible, but it's a very bad way I think.

2. Another problem is that I couldn't find any "minimize" procedure. Only the above mentioned ShowTodayScreen which always returns to Sense. If the user would run the ActionScreen in order to run a new window (such as new SMS) it's not a big problem. But if you want to trigger the BT or WiFi, returning to HomeScreen every time is annoying (aha, I forgot to mention that the program is triggered by holding the PowerButton for >3 secs to it's feature should be that it can be run from any place in the system)

3. Third problem is that even when the app runs in background it still takes over 600-700 kB which I consider as large for so light image it actually is. Furthermore I noticed strange behaviour when ActionScreen is not used for longer time. It takes more and more memory over time (a memory leak?) and "refreshes" itself when it's actually called. After 2 hours of system startup the ActionScreen.exe was taking more than 2MBs of memory (!!!)

4. When the app is running in the memory, no further arguments seem to work. I would like to let the user close the app by i.e. calling "ActionScreen.exe quit" command or link, but it doesn't work. The argument is only read when the program is started for a first time. Could you point me a way to close the app with "external" activity? Of course the I don't want the form to appear in the task manager, that's why it doesn't have any name.


My general question: Is there any way to make my app lighter to avoid taking so much memory (all the files of the program including the images and librarys take 493 kB, so how it is possible that this app takes 600 at startup and 2MB over time)?
I plan to add further controls to the app (i.e. Labels to make it possible to for the people to translate it to different languages, and perhaps additional shortcuts etc.) so the memory problem will be bigger an bigger. So I want to ask if I can somehow manage the memory in more "smart" way. Perhaps I should make 2 executable files, one to be in the memory "storing" resources and the other one to actually handle all the rest functions + rest of the images (i.e. pressed buttons). But is this possible to share the same resources from the RAM to 2 independent apps?

Enclosed please find my whole program with all the neccesary files. 3 remarks:

- the LongPower.lnk should be put in \Windows\ to make it possible to trigger the app by holding PowerButton.
- the ActionScreen_quiet.lnk should be put in \Windows\%Startup% folder to run the app in quiet mode duing system start.
- the first button (E-mail) is mapped only to AppClose just for testing purposes.

Thank you in advance for your kind help.
 

Skrobel

Member
Licensed User
Anybody? :sign0085:

Do you suggest I should change the language? That the B4PPC is not optimized enough to make it possible what I want?

But where should I take a look at first place? Visual Studio (for $550?) + some Windows Mobile SDK? I would love to continue using B4PPC though... I really like the simplicity of it. But the simplicity can be a disadvantage sometimes... :(
 
Top