Access Violation during planning of Fourier Transform
Little bit of background, I'm more experienced with Java, and have some C/C++ experience.
I'm using Visual Studios 2010.I created two classes inside a header file and gave them fields.
It compiles ok, and for the longest time it was running just fine. I copied the entire project directory to a new folder (all files inside) and simply recompiled and ran it. Now whenever I run it I get "Unhandled exception at 0x637779ab in RegistrationExpLib2.exe: 0xC0000005: Access violation writing location 0x00000000." At this lineFourierTrans[i] = fftwf_plan_dft_2d(imgRows, imgCols, in[i], out[i], FFTW_FORWARD, FFTW_MEASURE);
I checked the debugger, and all of the class fields return could not evaluate expression.
I've already checked and the image is being read in correctly. And as far as I can tell All of the memory has been allocated correctly. fftw3 is a C dll I'm linking against. So I'm really puzzled and was hoping someone could point out a possible issue. I'm thinking its either, I'm doing something wrong with the set up when I copied the Visual Studios Project(Even though I didn't change anything since it was working), or I've incorrectly allocated memory in the header. Another issue I thought of is each image is about 20MB, so I may be messing with the heap. I really appreciate any help.The Images being read in are frequently 10-20MB apiece. The code is compiled as a 32 b开发者_Python百科it binary.
This is the relevent simplified portion of the code that produces the crash.
#define TESTNUM 80
//A simple test main.
int main() {
ComplexImageFFTW a;
ComplexImageFFTW b[TESTNUM];
ComplexImageFFTW* ptrB;
ptrB = b;
printf("start\n");
a.readImage("imagefile1", true);
printf("Mission\n");
for(int i = 0; i < TESTNUM; i++) {
b[i].readImage("imagefile2", true);
}
//Crash occurs here.
FourierTrans[i] = fftwf_plan_dft_2d(imgRows, imgCols, in[i], out[i], FFTW_FORWARD, FFTW_MEASURE);
...
} //End main
Access violation writing location 0x00000000
means that you're trying to write to memory location 0x00000000
, i.e., you're writing to a null pointer. I think the pointer p
probably has the value 0.
Possibly you're forgetting to call your Registration::setUpRegistration
method?
After reading in the 80 plus images. The amount of Heap used was >1.7GB. Since this was compiled as a 32bit binary there are memory limitations of about 2GB. when the program went to plan the Fourier Transform it resulted in a failed memory allocation, which creates a null pointer. Then the program went to use the pointer, unchecked, resulting in an access violation error.
精彩评论