When trying to cut down possible memory leaks in my program, I noticed a reoccoring pattern: Move Delete closer to new, repeat, remOve the function that uses it and move code to main, move a few things to global, replace some stuff with arguments and return values, and in the end everything is in main with no pointers.
However to reassure myself that this wont have problems I want to know this : If my program doesnt use the stack or heap at all (as in me putting a new or stk()? in it) will it still have (however small) memory leaks? It was made to work forever constantly recalculating it's output every second, evaluating the time, year, day, ticks since start, CPU speed (<<in progress), so basically if you open this in DOS your doomed.
Zssffssz
-4
Junior Poster
Recommended Answers
Jump to PostUse the standard smart pointers, perhaps?
See: http://www.devx.com/cplus/10MinuteSolution/39071/1954
and: http://www.devx.com/cplus/10MinuteSolution/28347/0/page/1
Jump to PostIf my program doesnt use the stack or heap at all (as in me putting a new or stk()? in it) will it still have (however small) memory leaks?
If you don't create leaks, or use any libraries that create leaks, then it stands to reason that there won't be …
Jump to PostYou should just run your program in Valgrind and see the report afterwards about if there are any memory leaks. Or, use any other memory debugging tool.
Basically, memory leaks are a …
All 9 Replies
vijayan121
1,152
Posting Virtuoso
Zssffssz
-4
Junior Poster
Narue
5,707
Bad Cop
Team Colleague
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
Zssffssz
-4
Junior Poster
NathanOliver
429
Veteran Poster
Featured Poster
Zssffssz
-4
Junior Poster
Tumlee
42
Junior Poster in Training
MastAvalons
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.