Releasing a class instance

Questions regarding syntax

Releasing a class instance

Postby bobr » Thu Aug 04, 2011 11:52 am

I'm in the process of constructing a set of classes for handling linked lists. This is relatively easy to accomplish in C++ as memory can be allocated and freed when adding and releasing nodes to/from a list.

The problem that's worrying me is that if I use the command 'new' to add a node in kBasic, memory is being allocated with each new node. Now, how do I delete a node from the list? If I just assign 'null' to the node address, does the memory associated with this node get released (and any associated data pointers within the class), or am I going to have a problem with memory leakage? Or, have I got my wires totally mixed up!?
bobr
 
Posts: 31
Joined: Fri Mar 18, 2011 10:30 pm

Re: Releasing a class instance

Postby berndnoetscher » Sun Aug 07, 2011 5:56 pm

<<If I just assign 'null' to the node address, does the memory associated with this node get released (and any associated data pointers within the class),

This is the expected behaviour of the gc.
berndnoetscher
Site Admin
 
Posts: 1059
Joined: Tue Sep 25, 2007 9:37 am

Re: Releasing a class instance

Postby bobr » Tue Aug 09, 2011 5:29 pm

Thanks for your reply. I thought that should be the case. I just needed confirmation.
bobr
 
Posts: 31
Joined: Fri Mar 18, 2011 10:30 pm


Return to Coding Questions

cron