|
From: Raghunath Marella.S <ms...@ya...> - 2002-06-10 07:25:17
|
Hi Ioannis/Jason/Others,
Please find the piece of code where the memory
violation is seen. I have not deleted the pointer and
accessed after that. No error has been done from my
side.
int *EleTopo=new int[seneles*sennds];
char *NodeSign=new char[this->NNodes+1];
Similarly few other variables have been dynamically
allocated....
for(int i=0;i<seneles;i++)
for(int j=0;j<ncn;j++)
{
int cuEl = (theSubEle+ise)->SEtopo[i];
*(EleTopo+i*ncn+j)=(theElement+cuEl-1)->topo[j];
NodeSign[(theElement+cuEl-1)->topo[j]] =
'P';//All nodes are marked as positive initially.
}
After this piece of code, 'EleTopo' values are
printed and they confirmed to be correct.
After few lines of other code.....
for(int iel=seneles-1;iel>=0 ; iel--)
{
int iLocalForEle=0;
int curElement = (theSubEle+ise)->SEtopo[iel];
if(iel==seneles-1)
coutf << "\n Final element in the SE is...:"<<iel;
//newAdd
int AnyNode;
int noOfDf = 0;
NoOfNegNodes =0;
for(int j=0;j<ncn;j++)
{
AnyNode = *(EleTopo+iel*ncn+j);
int isThisNodeABN = 0;// is this a boundary node
of SE.
for(int it=0;it<SeBNodes;it++)
{
if(AnyNode ==
((theSubEle+ise)->SEBounNodes[it]))
{
isThisNodeABN = 1;
break;
}
else
isThisNodeABN = 0;
}
if(isThisNodeABN==0)
{
****** if(NodeSign[*(EleTopo+iel*ncn+j)]=='N')
{
//Do nothing...
}
else
{
NodeSign[*(EleTopo+iel*ncn+j)]='N';
int nde = *(EleTopo+iel*ncn+j);
****** *(EleTopo+iel*ncn+j) = -*(EleTopo+iel*ncn+j);
NoOfNegNodes++;
//saving the the dfs that are going to be removed
after this element being assembled.
for(int ir=0;ir<NDF;ir++)
{
*(DfToRemove+iel*(ncn*NDF)+iLocalForEle)=
(nde-1)*NDF+ir;
iLocalForEle++;
}
noOfDf+=NDF;
}
}
else
cout <<"\n this Node is a BoundaryNode of
SE...:"<<AnyNode<<".."<<ise;
}
noOfDf = iLocalForEle;
NoNegDf[iel]=NDF*NoOfNegNodes;
}//sign check ends here.....
The problem appears in the line marked with ******.
Actually this problem is seen only in some of the
problems. To give you more idea, I have tested this
code as standalone, it worked fine for 'EleTopo'
sized upto 3200*6, then it worked properly and no
memory violation was observed.
But, when the code used as a server implementation in
CORBA environment, the so called memory violation
took place when 'EleTopo' was sized to 800*6. Briefly,
'EleTopo' is like an two dimentional array of size
[800][6]. I have to access data in 'EleTopo' from the
end, ie., from [800][]. The values are correct till
[48][6] and started giving junk values for some of the
indexes between [47][] to [0][].
I have shown in array form just for illustration
purpose.
I am clueless how this memory violation is taking
place in some cases only.
Will you pls suggest me what is going wrong in this.
thanks & regards,
Raghunath
--- Ioannis Vranos <no...@ho...> wrote:
> > -----Original Message-----
> > From: dev...@li...
> > [mailto:dev...@li...]
> On Behalf
> > Of Jason Hardman
> > Sent: Monday, June 10, 2002 1:12 AM
> > To: Dev-C++
> > Subject: Re: [Dev-C++] memory violation....
> >
> >
> > You should check that "EleTopo" is non-null before
> using it,
> > just in case the memory allocation
> > failed. I can't remember if the current MinGW used
> with
> > Dev-C++ is standards compliant enought to
> > throw an exception when memory allocation fails.
>
>
> It is, and no, 0 can not be returned by new.
>
>
> Ioannis
>
> * Ioannis Vranos
> * Programming pages: http://www.noicys.cjb.net
> * Alternative URL: http://run.to/noicys
>
>
_______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application
> Developer's Conference
> August 25-28 in Las Vegas -
>
http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
>
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
|