C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 10th, 2003, 05:09 AM
FHCandyman FHCandyman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 FHCandyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
deleting references from the free store.

ok, this book i am reading says the references cannot be null, but leaving them can create memory leakage. so how exactly do i delete them and prevent memory leakage? heres what the book says but i do not understand it:

The third workable solution, and the right one, is to declare the object in the calling function and then to pass it to TheFunction() by reference.

The best I can interprete it is to create the object within the function, and then return the value of that object with a reference to the object. how does this delete the reference? is it that, since it points to a local variable, it gets deleted when the function ends? a lot of that i just thought up of now So did I get that right? I dont want to guess and get it wrong because the book scares me in the ways it talks about invalid programs

Reply With Quote
  #2  
Old August 10th, 2003, 05:44 AM
BigBadBob BigBadBob is offline
status unknown
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 262 BigBadBob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Can you show us the context in which it says that leaving references can create memory leakage?

Reply With Quote
  #3  
Old August 10th, 2003, 09:48 AM
FHCandyman FHCandyman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 FHCandyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> To prove that the reference declared in main() is referring to the object put on the free store in TheFunction(), the address of operator is applied to rCat(the reference object). Sure enough, it displays the address of the object it refers to and this matches the address of the object on the free store.

So far, so good. But how will that memory be freed? You can't call delete on the reference.

So I figure you have to do something that will have the same effect as delete, which is freeing up memory on the free store, correct?
It relates to an example but I hope you can figure out what it means. It just calls the address operator on an object and a reference, and it displays the same address, meaning that the reference at least refers to something on the free store.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > deleting references from the free store.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT