Re: debugging a seg fault

From: John <idarraga_at_cern.ch>
Date: Thu, 6 Nov 2008 13:55:43 -0500


Hello,

Well, it means you have 48 pointers to Int_t, and each array of size 'nenergies*4'bytes somewhere in the heap. I would put everything on the heap, but that's your choice. So it should be fine now even for large numbers of 'nenergies'. Just make sure you clean up properly at the end.

delete [] word

cheers !

John Idarraga
UMontreal

Roger Mason wrote:
> Hello John,
>
> John <idarraga_at_cern.ch> writes:
>

>> You are probably blowing the stack defining that matrix in that way.
>>

>
>> Move your stuff to the heap memory, it means ... allocate your "word"
>> matrix using the "new" operator.  If you don't know how to implement it
>> let me know.

>
> Many thanks. At the back of my mind after I sent the message the words
> "heap" and "stack" appeared, but too late!
>
> I now have
>
> Int_t (*word)[48];
> word = new Int_t[nenergies][48];
>
> and it compiles and runs, at least when the value of nenergies is only
> 6.
>
> Thanks again,
> Roger
>
Received on Thu Nov 06 2008 - 19:57:23 CET

This archive was generated by hypermail 2.2.0 : Thu Nov 06 2008 - 23:50:02 CET