Re: Is this a memory problem?
- From: Bryan Heit <bjheit@xxxxxxxxxxxxxxxxx>
- Date: Wed, 05 Jul 2006 08:30:49 -0600
Jean-David Beyer wrote:
Bryan Heit wrote:
Patrick wrote:
"syang8" <syang8@xxxxxxxxx> wrote in message
news:1152036094.699638.87890@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
I use Kdevelop to build some scientific simulation on Linux. If I set
the size of an array N = 8000, the program works fine. However, if I
set the array N some number greater than 10000 (actually, what I need
is 80000), the program has segmentation error. The intersting thing
is that the positions reporting segmentation error are different if
I set N to be different values.
What problem is this usually?
It's a problem with the faulty program code, always. Debug your
application
carefully step-by-step to discover the cause.
My guess is the problem is in the way you are accessing the array. I've
made the same mistake myself on more then one occasion.
I think that you're using a too small an integer for storing array
locations. For example, a 16-bit pointer can only describe ~65,500
unique array positions. So for an array with more then ~65,500 elements
you'll need a larger (i.e. 24-bit or 32-bit) pointer to access the
array. This would explain why your code works fine with smaller arrays
but fails with larger ones.
Bryan
Well, sort of. I believe all pointers these days, on 32-bit machines, are 32
bits.
It depends on the programming language. I don't know Kdevelop, but some programming languages allow you to pick the size of integer you use to reference the pointer. This was common in older languages, although I think that you can still do this in C/C++. I don't think that java and newer languages allow you to do this.
Bryan
.
- Follow-Ups:
- Re: Is this a memory problem?
- From: Jean-David Beyer
- Re: Is this a memory problem?
- References:
- Is this a memory problem?
- From: syang8
- Re: Is this a memory problem?
- From: Patrick
- Re: Is this a memory problem?
- From: Bryan Heit
- Re: Is this a memory problem?
- From: Jean-David Beyer
- Is this a memory problem?
- Prev by Date: Re: Repairing jpg images
- Next by Date: Re: Is this a memory problem?
- Previous by thread: Re: Is this a memory problem?
- Next by thread: Re: Is this a memory problem?
- Index(es):
Relevant Pages
|