WorkingSet vrs WorkingSet64

Recently I’ve been doing a lot of work with the Process.GetCurrentProcess() method and since the application I am building is being developed on the 2.0 64bit framework, I was worried that if I used Process.GetCurrentProcess().WorkingSet64, that the application wouldnt work with 32bit OS’s, since WorkingSet was deprecated, but not enforced.

After some thought though, I realised that the WorkingSet returns the amount of memory being used by the process as an integer (32 bit signed integer). OK, so the maximum value of an integer is 2,147,483,647 — which is remarkably close to the total amount of memory that a process can have in its working set.  Except, there is actually a switch in Windows that will allow a process to use 3 gig of memory instead of 2 gig.  So what would happen when you poll the WorkingSet you will get a negative number, a really big small negative number. Usually, in the realm of -2,147,482,342.  As the more perceptive of you have guessed the problem already.  The overflow bit.

So you ask, why didn’t Microsoft just change the API so WorkingSet returned an Int64 instead of an Int32.  Well they could, except that they would break applications built against version 1.0 and 1.1 frameworks, as this post explains.

But after all this pondering, it turns out that WorkingSet64 des exactly what WorkingSet does, except returns an Int64 instead – and as such is less prone to breaks.  Works with both 32bit and 64bit Windows and Frameworks and all is good with the world.

Life. Be In It.

The last year has really been the hardest of my life.   My healthy life goals serriously handicapped by a semi-recent diagnosis of Atypical Depression.  After talking to some people who have previously dealt with the illness themselves, and after going and seeing my GP – I am happy to say that life is starting to get its colour back.

Being the end of a year which has been particularly difficult for me I thought that it would be an ideal time to renew some old commitments which have fallen by the wayside.

Thanks to a kind heart, and great generosity, my wife’s grandmother has given me $100 to buy something for myself for Christmas.  So, instead of getting an electric shaver or a DVD Boxset or something, I bought a Mountain Bike.  I found a bargain at Target, and while I was initally prepared to pay the extra $100 – $150 for the bike, the checkout girl only charged $130 for it (hehe.)

I didn’t correct her.

So my plan is to bike to the train station nearest me (Home > Kuraby Station about 6.5Kms) and train to one near work (Yerongpilly Station > Work about 4.5Kms) each day.  Later I hope to just go the whole distance.

I don’t want to be overweight and unhappy anymore.