# Saturday, 27 January 2007

But I'm not in that some minority! :P

Saturday, 27 January 2007 01:48:14 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [1]  | 
# Wednesday, 24 January 2007

7 days ago I was rudely awakened by my wife telling me her stomach was hurting, and she felt like shitting, and my son was born soon after.

Better put some more pictures up now as any good father would do!

It's just so hard to get a good picture..

Stop squirming...

There.. this will do I guess! ;)

And of course.. the coup de grace..

Wednesday, 24 January 2007 22:56:09 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [3]  | 
# Tuesday, 23 January 2007

So.. you've got this cool Pocket PC .Net CF 2.0 application, which reads off a SQL Server Compact Edition database, everything works fine when you're in debugging mode, then as you're testing the app you get the dreaded OutOfMemory exception thrown when you try to open a connection to the database.

You go to the memory app under settings and notice that the Pocket PC only has 1MB of program memory left, obviously it can't load the SQLCE runtime AND do your queries at the same time. You hit the running programs tab and select close all, but you don't expect a user to do that. There must be a better way to do this!

The OS is supposed to close applications in low memory situations, but exactly how low is LOW? Gleamed from the Pocket PC SDK we find this little tidbit:-

The Shell in a Windows Mobile-based Smartphone sends WM_CLOSE messages if there is less than 128 KB of free memory. The shell does not send WM_CLOSE messages if you ask for more memory than is available. For example, the Smartphone does not allocate 200 KB of memory if it only has 190 KB free. Instead, the shell displays an Out Of Memory dialog box to the user.

Wow.. 128KB is what the OS considers to be low... so what can we do about it? Well we call the function which the snippet above was taken from, SHCloseApps. What this API function does is that you pass the amount of memory you want and the OS will keep sending WM_CLOSE messages to applications until the memory requested is achieved. To use the function in your PPC program first you need to declare the P/Invoke in your class (For C# examples.. well start reading the documentation on how to do P/Invokes!)

Public Declare Function SHCloseApps Lib "aygshell" (ByVal MemorySought As Int32) As Boolean

Then when you need to, just call the function with the number of bytes of memory you need.


Simple and gets the job done, before I did this my app kept getting OutOfMemory exceptions (no thanks to the RSSReader, GPS Map program AND Pocket IE) during execution. Now it just works... like it should.

PS. Here's another tip, you might want to use this function if you ever want the user to take a picture with the device's builtin camera, cause they usually need about 1~2MB to take a 1MP picture, so be sure to free up some memory BEFORE you show the picture selector dialog box.

Tuesday, 23 January 2007 00:29:19 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [3]  | 
# Sunday, 21 January 2007

Turn off the bloddy rate limiting switch on RDP sessions already so my colleagues can go RDP into the servers and not have to come ask me to manually tweak the coonnections already!

I already have my hands full taking care of my wife and baby already you know!

Sunday, 21 January 2007 21:19:25 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [0]  | 
# Thursday, 18 January 2007

I treat my gear very carefully, I gently slide my notebooks in and out of the bag, I only torture my touch screen s after I put a screen protector on them. I die a little inside when anything bad happens to my gear, like when my M200 dropped cause of a faulty bag strap,or where my phone dropped to the ground cause I missed the holster.

So, imagine my surprise that this kind of gentle attituide doesn't apply when taking care of babies.  When I try to bundle him up and he fights back I'm too scared to apply too much force cause I'm afraid I might dislocate his arm or something, worse when trying to change a diaper and he's just kicking wildly while I'm trying to clean his butt.

Whereas my wife who has taken care of a lot of her nieces and nephews just pushes the little guy's arms down, or just yanks the legs straight and proper when doing a diaper change. She asks me why do I find it so hard to force a baby's down, I ask her isn't she afraid of breaking anything cause I'm just trying to be careful here. She just tells me to just give them the push and the baby should get the idea already.

Ok then... we'll see what happens after a few more tries.

Thursday, 18 January 2007 17:24:10 (Malay Peninsula Standard Time, UTC+08:00)  #    Comments [4]  |