Click here to Skip to main content
15,914,231 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCObject::operator new() Pin
PJ Arends8-May-05 21:31
professionalPJ Arends8-May-05 21:31 
GeneralRe: CObject::operator new() Pin
Zdeslav Vojkovic8-May-05 22:34
Zdeslav Vojkovic8-May-05 22:34 
GeneralRe: CObject::operator new() Pin
PJ Arends9-May-05 7:09
professionalPJ Arends9-May-05 7:09 
Generalabout shutdown dialog box Pin
feitianli_38-May-05 21:25
feitianli_38-May-05 21:25 
GeneralRe: about shutdown dialog box Pin
P-Rex8-May-05 22:09
P-Rex8-May-05 22:09 
GeneralRe: about shutdown dialog box Pin
ThatsAlok8-May-05 22:20
ThatsAlok8-May-05 22:20 
GeneralRe: about shutdown dialog box Pin
feitianli_39-May-05 15:39
feitianli_39-May-05 15:39 
GeneralMemory leak.... vector of pointers.... Pin
franz19998-May-05 20:22
franz19998-May-05 20:22 
This code:
void Model3D::smooth() {<br />
	vector<Vertex*>* newVertices = new vector<Vertex*>;<br />
	float avg = 0.0f;<br />
	// applying umbrella operator<br />
	for(int i=0; i<vertices->size(); i++) {<br />
		Vertex *oldV = vertices->at(i);<br />
		Vector3D pOld = Vector3D(oldV->x,oldV->y,oldV->z);<br />
		Vector3D d = Vector3D(0.0f,0.0f,0.0f);<br />
		int numOfVertices = 0;<br />
		for(int j=0; j<oldV->edges->size(); j++) {<br />
			Edge* e= edges->at(oldV->edges->at(j));<br />
			Vertex* v= vertices->at(e->vertices->at(0));<br />
			if(v->id == oldV->id)<br />
				v= vertices->at(e->vertices->at(0));<br />
			numOfVertices++;<br />
			Vector3D qi = Vector3D(v->x,v->y,v->z);<br />
			d = d + (qi-pOld);<br />
		}<br />
		d = d / (float)numOfVertices;<br />
		d = d * ALPHA;<br />
		avg += sqrt(d.x*d.x + d.y*d.y + d.z*d.z);<br />
		Vector3D pNew = Vector3D(0.0f,0.0f,0.0f); <br />
		pNew = pOld + d;<br />
		Vertex *newV = new Vertex(oldV->id,pNew.x, pNew.y, pNew.z);<br />
		newVertices->push_back(newV);<br />
	}<br />
	avg = avg / vertices->size();<br />
	for(i=0; i<newVertices->size(); i++) {<br />
		Vertex* v = vertices->at(i);<br />
		Vector3D n = Vector3D(v->nx,v->ny,v->nz);<br />
		n = n * avg;<br />
		v->x = v->x + n.x;<br />
		v->y = v->y + n.y;<br />
		v->z = v->z + n.z;<br />
	}<br />
	// copying back the values<br />
	for(i=0; i<vertices->size(); i++) {<br />
		Vertex *oldV = vertices->at(i);<br />
		Vertex *newV = newVertices->at(i);<br />
		oldV->x = newV->x;<br />
		oldV->y = newV->y;<br />
		oldV->z = newV->z;<br />
		delete newV;<br />
	}<br />
}<br />

shows an incredible consumption of memory in the Win task manager when it is run several times over the same Model3D object... ideally NO memory should be used... can anyone help, please?

thanks,

FG
GeneralRe: Memory leak.... vector of pointers.... Pin
jmkhael8-May-05 23:37
jmkhael8-May-05 23:37 
Generaltell me a solution...if u can Pin
VCSharp0078-May-05 19:32
VCSharp0078-May-05 19:32 
GeneralRe: tell me a solution...if u can Pin
Christian Graus8-May-05 19:35
protectorChristian Graus8-May-05 19:35 
GeneralRe: tell me a solution...if u can Pin
VCSharp0078-May-05 20:21
VCSharp0078-May-05 20:21 
GeneralRe: tell me a solution...if u can Pin
David Crow9-May-05 5:04
David Crow9-May-05 5:04 
GeneralRe: tell me a solution...if u can Pin
VCSharp0079-May-05 17:31
VCSharp0079-May-05 17:31 
GeneralRe: tell me a solution...if u can Pin
David Crow10-May-05 2:06
David Crow10-May-05 2:06 
GeneralRe: tell me a solution...if u can Pin
VCSharp00710-May-05 23:58
VCSharp00710-May-05 23:58 
GeneralRe: tell me a solution...if u can Pin
David Crow11-May-05 2:24
David Crow11-May-05 2:24 
Generalcheck a string if it is a number Pin
Anonymous8-May-05 19:27
Anonymous8-May-05 19:27 
GeneralRe: check a string if it is a number Pin
Christian Graus8-May-05 19:34
protectorChristian Graus8-May-05 19:34 
GeneralRe: check a string if it is a number Pin
Ted Ferenc8-May-05 21:26
Ted Ferenc8-May-05 21:26 
GeneralRe: check a string if it is a number Pin
PJ Arends8-May-05 21:26
professionalPJ Arends8-May-05 21:26 
GeneralRe: check a string if it is a number Pin
namaskaaram8-May-05 23:30
namaskaaram8-May-05 23:30 
Generalhelp regarding inheritance Pin
Usman Arif8-May-05 18:38
Usman Arif8-May-05 18:38 
GeneralRe: help regarding inheritance Pin
Christian Graus8-May-05 18:42
protectorChristian Graus8-May-05 18:42 
GeneralRe: help regarding inheritance Pin
Usman Arif8-May-05 19:24
Usman Arif8-May-05 19:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.