Strange hanging symptoms on Duemilanove

I have a program of 17,906 bytes and it behaves very strangely, in that it hangs on lines of code even before it reaches them.
It hangs on say lcd.print lines using a 4 line display, if I delete the last 2 lines then it then doesn't hang anymore. I have code calling the lcd in 10 places and confident it's not a programming bug.

Another example to quote code is:

void decode_one_key ()
{
menuoptions = 1;
}

This above works fine. But I had to cut out lines from the original else it hung.

This version below crashes, the serial monitor crashes and all but odly well before this line is reached.

void decode_one_key ()
{
if ( menuoptions == 1 ) // then this pressing of 1 must be to pick auto mode so lets set it to 1
{
numbercalc(1);
}
else
{
menuoptions = 1;
}

}

I have had other occurrences of it hanging well before it reaches line of code.

It behaves as if I have hit a memory limitation.

It behaves the same if running in serial monitor or standalone.

I will be very grateful for a pointer on how to overcome this issue.

Many Thanks
Les

I have a program of 17,906 bytes and it behaves very strangely

But you didn't consider posting it?

It behaves as if I have hit a memory limitation

I'd check your RAM usage.

Can post the code it, exceeds the size limit of this forum.

Happy to email if requested.

Have run this code to check memory:
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

Serial.println("\n[memCheck]");
Serial.println(freeRam());

Memcheck responds with 97

Is that my problem ?

If so, is there an arduino with more ram ?

Thanks & Rgds
Les

Can post the code it, exceeds the size limit of this forum.

As far as I'm aware there are no size limits to attachments.

If so, is there an arduino with more ram ?

Than a 2009? Yes, of course.
You may not need more RAM if you manage the RAM you have correctly.

Please remember to use code tags when posting code.