🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.os2.programmer.tools
1 messages
1 total messages Started by Mark Framness Wed, 28 Jan 1998 00:00
VA C++ Memory Debugging
#36
Author: Mark Framness
Date: Wed, 28 Jan 1998 00:00
137 lines
5105 bytes
Greetings

I am working on an exercise (an OOP C++ course) regarding the overloading of
the assignment operator also I'm to define two different + operators (one for
a stack + character and another for 
stack + stack).

Now I believe I'm pretty close to getting the assignment done (it seems to
work) and I do not see any place where I'm obviously doing goofy things to
memory, but the longer I work and debug the program the more goofy the system
becomes (one thing was a minimized icon for my e-mail package changed on its
own and things take longer etc).  So I figured I might need to look at my
memory use in more detail.  I don't see any obvious places where I would have
dangling pointers or am deleting already deleted objects.  I'm using copy
constructors as well as the defined assignment operators in order to avoid
such things.

So I enabled the /Tm option on the VA C++ compiler (I'm using the workframe)
and then added the _dump_allocated(10) function at the end of the program.

What I am doing is to allocate two stacks with the below given ctor which will
construct a stack if an integer size is given.  Then I push on characters with
the given function.  That is all I do here and then when I run the program I
get the below given dump.

Questions:
How do I basically interpret the dump?

How does it relate to the map file generated by the linker?

Do the dumps necessarily indicate an error?  I ran a program from Dave
Bricetti's homepage (a little thing designed by him to demonstrate the memory
debugging function of VA C++) and it dumps on an errorless allocation.  I
guess I just answered my own question.

How may I redirect the dump to a file?

Thanks for any & all help.

/*********************************/
//Basic functions of the program below.
//I hope the ctor below gives the spirit well enough.  
//In my copy ctor I am essentially using the ctor below with the addition of
//a memcpy() function.

//another ctor specifying the size of the stack.
/***************************************************************************/
stack::stack(int big)
{
size=big;
if(!(stck=new char[size]))
   {
   cout << "Memory allocation error." << endl;
   exit(1);
   }
tos=0;
}
/***************************************************************************/

// Push a character.
/****************************************************************************/
void stack::push(char ch)
{
if(tos==size)
   {
   cout <<"Stack is full\n";
   return;
   }
*(stck+tos)=ch;
++tos;
}
/***************************************************************************/

main()
{
stack s1(3);
stack s2(3);

while(s1.not_full())
   {
   cout << "Pushing onto s1." << endl;
   s1.push('a');
   }

while(s2.not_full())
   {
   cout << "Pushing onto s2." << endl;
   s2.push('b');
   }


_dump_allocated (10);
return 0;
}

------------------------------------------------------------------------------
-
                 START OF DUMP OF ALLOCATED MEMORY BLOCKS
------------------------------------------------------------------------------
-
Address: 0x000B39E0      Size: 0x00000003 (3)
This memory block was (re)allocated at line number 146 in
D:\C++\RedWing\MARKF3H
CPP.
Memory contents:  626262                                 [bbb             ]
------------------------------------------------------------------------------
-
Address: 0x000B39A0      Size: 0x00000003 (3)
This memory block was (re)allocated at line number 146 in
D:\C++\RedWing\MARKF3H
CPP.
Memory contents:  616161                                 [aaa             ]
------------------------------------------------------------------------------
-
                 END OF DUMP OF ALLOCATED MEMORY BLOCKS
------------------------------------------------------------------------------
-


Take Care!

postmaster@[127.0.0.1]  
Spam booby trap!!!

FROM:  Mark Allen Framness
HOME:  framness@.NO_SPAM.EMIRATES.NET.AE
WORK:  m477@NO_SPAM.ugru.uaeu.ac.ae
HTTP:  http://netnet.net/~farmer/index.html

URL for comp.lang.c NG:  http://www.eskimo.com/~scs/C-faq/top.html

To reply via e-mail, delete the given reply to address and delete the NO_SPAM
from the above addresses.
					&
All standard disclaimers apply.  Anyone who says otherwise is itching for a
fight.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads