Turns out we hadnt implemented the copy constructor on the class, so when it was on teh stack, the compiler just copied it all easily, when we started using pointers to the memory on the heap, the compiler only copied the pointer over, so we got errors!
Watch out for the same sort of problems with the assignment operator as well, the default assignment operator will just do a bitwise copy of the pointers so in the case of "a = b;" internal pointers in "b" will now point to the same location in memory as the equivalent pointer in "a" and the memory "b"s pointer was pointing to is now lost for good (memory leak). The copy constructor won't leak but the assignment operator will. I guess you had the issue of trying to delete memory that had already been deleted as well huh? Prolly not what you want. Scott Meyers "Effective C++" has a great section on this, I have the second edition and there is now a third edition so I hope I'm still up to date lmao...... It's a great book and the more I read it the more I understand (understood almost nothing the first time i read it).
What was the stack limit and how would you test for that? Is the stack limit machine specific or is it fairly standard?
To answer my own question "ulimit -s" will tell you the stack size 10MB in my case, seems to be fairly standard for l8 model linux.
Still don't know how to test for it though.... monk?
Cheers,
td