Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Memory leakage ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 45680 of 48044
Post > Topic >>

Memory leakage problem

by luke <sirix@[EMAIL PROTECTED] > May 1, 2008 at 12:17 PM

Hi,
my program has a memory leak and I can't handle it.
Basically, there are two cl*****, class_a and class_b, and one 
object of each class: class_a obj_a, and class_b obj_b. 

One of the methods of class_a is basically

float* class_a::get_data(int n) {
	float *to_return = new float[n];
	.. 	//computing entries in to_return
	return to_return;
}

and one of the methods of class_b is basically

void class_b::use_data() {
	float* data;
	data = pointer_to_class_a -> get_data(s) ;
	.. //using data;
	delete [] data;
}

where s and pointer_to_class_a are members of class_b, and the latter
points to obj_a.
The method use_data() is used many times in the program, and it's the 
only place where get_data(int) is used. However, the size of the program 
(re****ted by top in linux)
increases drastically in time (use_data is used many times a second). 

What do I do wrong? (to be honest, there are some other uses of new in 
the program, but I don't suppose they are significant).

Best,
Lukasz Grabowski
 




 6 Posts in Topic:
Memory leakage problem
luke <sirix@[EMAIL PRO  2008-05-01 12:17:50 
Re: Memory leakage problem
Lionel B <me@[EMAIL PR  2008-05-01 12:32:59 
Re: Memory leakage problem
Juha Nieminen <nospam@  2008-05-01 12:52:18 
Re: Memory leakage problem
luke <sirix@[EMAIL PRO  2008-05-01 15:22:06 
Re: Memory leakage problem
peter koch <peter.koch  2008-05-01 06:47:24 
Re: Memory leakage problem
Puppet_Sock <puppet_so  2008-05-01 07:11:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:33:48 CDT 2008.