Thursday, August 31, 2006

Tech Stuff : Dodgy Memory Leaks

Having spent over a week trying to find a memory leak in an app I am developing for Windows Mobile I finally found it today.

The app I have developed is a Today screen plugin. It works happily with no problems for around 8-10 hours and then suddenly it stops displaying and the device starts struggling to do anything else until it is reset...definite symptoms of a memory leak.

OK, so down to finding the leak. Fortunately I had made a desktop test application for testing today plugs so it should be fairly easy to track it down..so I thought. I ran my test app and monitored its memory with performance monitor, but everything appeared fine...no leaks!!!!

I checked every line of code to make sure there were no potential problems...I didn't see any.

After a few days of trying one thing after another I was starting to suspect that perhaps one of the system DLLs on the device may be corrupted and was leaking memory...but I figured this couldn't be the problem as all other apps seemed to behave OK.

I downloaded a trial version of Rational Purify which detects memory leaks...but this didn't find any!

Last night I had a breakthrough whereby I reset the mobile device and then attached to the process via Visual Studio 2005. I could then break into the code whenever I wanted to see what was going on. I left it running overnight and this morning, sure enough the app was not displaying again. I then stepped through my code and found out that the line that was erroring was a RegOpenKeyEx call. This call was returning with an out of memory error!

I realised that the memory error was a bit misleading as what it was actually telling me was that there were no more handles available...somewhere in my code I was not closing a handle, and sure enough I found one place where I was doing this. I fixed the code and now no memory leak!!!

So the moral of the story is don't assume memory leaks can occur just because of malloc, realloc and new, but also the system has a limited number (although big) number of handles and therefore all handles should be released (especially if you are polling files and/or the registry as in my case).

Tuesday, August 29, 2006

Mountain Trek

A few weekends ago I trekked up the mountain behind our house. It's certainly not on the scale of Mount Everest but it was still a challenge at 1200 metres and the days temperature was around 30 degrees centigrade. I've included some snaps from my mobile phone to show you the stunning views.

Annecy.....

South Shore of Lake Annecy.....

Veyrier du Lac.....

Mont Blanc in the distance.....

Monday, August 28, 2006

Début d'école pour mes enfants

Today is a special day, particular for Emily and Sophie, as today they start school. It is going to be very exciting for them both as they will be 2 little English girls amongst a class of French children. Everyone has told us that they will learn French just like that, I think Emily knows a lot more than she thinks she does (as she is constantly teaching me).

The start of the day was fairly easy, I awoke before the alarm and the girls got up straight away as then were very excited. They got dressed, had breakfast and got ready to go. We all piled into the car and took them to Emily's school. There were lots of children and parents there and we had a chat with the headmaster (who wants me to help test 28 secondhand computers that the school has just received). I went back to the car as Sophie and Poppy were still in the car.

A few minutes later, Sarah and Emily came back to the car. Apparently Emily and Sophie do not start until the afternoon as only the older children start in the morning. I couldn't believe after all the military operations to make sure they get to school on time at 8:30am, they don't actually have to start until 1:30pm! A big disappointment for the girls, but at least Emily gets to go to the shops to spend her tooth mouse/fairy money!


The girls finally went to school at 1:30. We took Sophie into her classroom which was full of lots of small French children. Sarah spoke to the teacher who explained some stuff to us...I just smiled and nodded as I hadn't a clue what she was saying. We then left Sophie sitting with some girls at a table who were drawing.

At 4:45 Sophie and Emily came home from their first day at school. The were both really happy and had big smiles. Emily said she wanted to go to school forever, so I think its safe to say she did really enjoy it. Apparently in the car on the way home, they were all asking their angels to make sure I get a job so they can stay at this school, so no pressure on me :)

Tuesday, August 22, 2006

I've finally done it!

Well having spent the last few months reading other peoples blogs, I have finally got around to creating one for myself. Not sure what I'm gonna put on it yet...but here's my first real blog...

Having spent the last year working for myself ( on my own (at home (in isolation ( in the basement ( although I have my own toilet) ) ) ) ) I have decided that it sucks. I need people interaction and I need to get out a bit more...so I've decided to try and find a proper job. Not totally sure what I want to do yet, but it has to be creative, graphical and pay loadsadosh :). It would also be nice to use some of the skills I learn't on my Masters Degree in Computer Animation that I did last year at Bournemouth University (UK).

Having moved to France last year, I can honestly say my language skills are poor. I get absolutely zero interaction with the locals, all our friends are English and the French friends that I do know, who are married to English speakers, speak English perfectly so they don't waste their time with me.

An example of how bad my French is, was yesterday when I spotted a small boy in our garden climbing our hedge. I couldn't even go out and tell him to "F Off before I get the dogs out" so I just stood and stared at him. The silence and and stance worked and he soon disappeared (after retrieving his ball).

I finally received the boxset of the "Comic Strip presents" yesterday (39 episodes) and the next episode is screaming out to be watched. If you haven't heard of or seen any of the Comic Strip stuff, then you are missing some classic cutting edge comedy from the 80's...try to catch "Bads News", "More Bad News" and "Fistful of Travellers Cheques" Heeeeeeelarious.

Fin.