[問題] 副程式內動態矩陣值會爆掉嗎??? 我這是什麼情形???
個人習慣把程式模組化
都使用副程式 或是 INCULDE .CPP
但是我今天碰到了一個嚴重問題 而我毫無頭緒
--------------------問題------------------
我的副程式在第一次RUN都很正常
但是多RUN幾次 所有值都亂掉
EX 我的矩陣裡面的值只有 0跟1
但是多跑了以後會出現好幾萬
------------------個人觀念----------------
就我所知 副程式內動態矩陣每次做完有DELETE的話
內容不會累積或是重疊 而且!!! 每做完一次副程式都會清空(釋放)才對!!!
------------------------------------------
我想請問 是否是配置過多動態矩陣才此呢?
造成沒有多的記憶體可用嗎?
使用工具 BCB6 以下是範例
void xxx()
{
//宣告 總共有9組 二維動態陣列
//OriH = 150 OriW =200 SizeX=7 SizeY=7
float **Temp1,**Temp2,**GradientX,**GradientY ,**VectorX,**VectorY ,**Orientation;
int **Gray,**Cadidate;
Byte *ptr;
Graphics::TBitmap *TheBitmap=new Graphics::TBitmap;
TheBitmap->Assign(Form1->Image4->Picture->Bitmap);
OriW=TheBitmap->Width;
OriH=TheBitmap->Height;
Gray=new int*[OriH];
Temp1=new float*[OriH];
Temp2=new float*[OriH];
GradientX=new float*[OriH];
GradientY=new float*[OriH];
VectorX=new float*[OriH];
VectorY=new float*[OriH];
Orientation=new float*[OriH/SizeY];
Cadidate=new int*[OriH/SizeY];
for(int y=0;y<OriH/SizeY;y++)
{
Cadidate[y]=new int[OriW/SizeX];
Orientation[y]=new float[OriW/SizeX];
}
for(int y=0;y<OriH;y++)
{
Gray[y]=new int[OriW];
Temp1[y]=new float[OriW];
Temp2[y]=new float[OriW];
GradientX[y]=new float[OriW];
GradientY[y]=new float[OriW];
VectorX[y]=new float[OriW];
VectorY[y]=new float[OriW];
}
-----------------------------------------------------------------
程式內容...
...........
...........
-----------------------------------------------------------------
//清除
for(int y=0;y<OriH;y++)
{
delete []Gray[y];
delete []Temp1[y];
delete []Temp2[y];
delete []GradientX[y];
delete []GradientY[y];
delete []VectorX[y];
delete []VectorY[y];
}
for(int y=0;y<OriH/SizeY;y++)
{
delete []Orientation[y];
delete []Cadidate[y];
}
delete []Cadidate;
delete []Temp1;
delete []Temp2;
delete []GradientX;
delete []GradientY;
delete []VectorX;
delete []VectorY;
delete []Orientation;
delete []Gray;
delete TheBitmap;
}
除了Byte *ptr外
每一個都有刪除
請問有人遇過如此詭異的問題嗎????????
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.64.88.58
推
02/09 18:03, , 1F
02/09 18:03, 1F
→
02/09 18:12, , 2F
02/09 18:12, 2F
推
02/09 18:25, , 3F
02/09 18:25, 3F
→
02/09 18:26, , 4F
02/09 18:26, 4F
→
02/09 18:47, , 5F
02/09 18:47, 5F
→
02/09 18:47, , 6F
02/09 18:47, 6F
→
02/09 19:27, , 7F
02/09 19:27, 7F
→
02/09 19:28, , 8F
02/09 19:28, 8F
推
02/09 19:37, , 9F
02/09 19:37, 9F
→
02/09 19:39, , 10F
02/09 19:39, 10F
推
02/09 20:19, , 11F
02/09 20:19, 11F
→
02/09 20:20, , 12F
02/09 20:20, 12F
→
02/09 20:21, , 13F
02/09 20:21, 13F
→
02/09 20:21, , 14F
02/09 20:21, 14F
推
02/09 20:48, , 15F
02/09 20:48, 15F
→
02/12 19:41, , 16F
02/12 19:41, 16F
推
02/16 01:10, , 17F
02/16 01:10, 17F
→
02/16 01:14, , 18F
02/16 01:14, 18F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章