dynamic memory allocation

I have a problem while running a program. I am running out of memory.
What I have done is allocated memory dynamically, using "new" and deleted it after finishing it's use using "delete".

But the memory isnt sufficient to run the program. I have talked about this issue with my teacher and they said that there must be memory leak somewhere.

I have tried using valgrind but I dont have any idea how to use it.

Is it better idea to make an object without allocating dynamically? For eg-
in place of doing

int *a = new int;

is it better to do
int a;

so that there wont be a memory leak.

Only use dynamic memory allocations if you have to.

If you have valgrind installed you should just have to run it as
valgrind [the command you use to run your program]
Topic archived. No new replies allowed.