Garbage Collection in C++

This is a discussion on Garbage Collection in C++ within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm a not a beginning programmer but I am comparatively a beginner since I can't understand how to use ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    32

    Garbage Collection in C++

    Hi,
    I'm a not a beginning programmer but I am comparatively a beginner since I can't understand how to use the Hans Boehm Garbage Collector with my program.

    http://www.hpl.hp.com/personal/Hans_Boehm/gc/

    I am making a big program right now and am experiencing increasing page file usage, which leads me to believe I have a memory leak. I have traced my entire code as much as possible but I haven't ventured into my SDL header files. (I use graphics).

    After some research I dicovered the "wonders" of garbage collection, and downloaded the formerly mentioned gc.

    But alas!
    Nowhere to be found is a step-by-step introduction as to how to use this wonderous tool! I'm talking about:
    1. Where from and what exactly to dowload.
    2. How to make sure I extracted all files correctly.
    3. How to set up my Dev-Cpp compiler (if needed) and my code to use the GC.
    4. How to actualy invoke memory cleanup sweeps, that is, if I must, in my program's loop...

    Please help...

  2. #2
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,236
    Why you don't take a look at your link?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    25
    I'm not sure implementing a garbage collector in C++ is would be worth the effort. Why don't you use a smart pointer instead, like the Boost shared_ptr? Of course, you can whip out your own in a couple of minutes, too.
    ...And I'm sorry I don't know the answer to your exact question
    Last edited by manannan; 09-29-2006 at 10:24 PM.

  4. #4
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Also, when using SDL, be sure to pay attention that there are a lot of "hidden pointers" inside SDL that can be a real pain... like every SDL_SURFACE needs to be freed with SDL_FreeSurface(), etc.

    When I use SDL I often write C++ wrappers around the SDL just for the purpose of providing automatic cleanup.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    32
    Yeah!
    That was the problem!
    I traced my program carefully by commenting out section by section and watching my PF usage on the windows task manager and found out that every time anything was written using SDL_ttf there would be a constant increase in PF usage of 3mb/sec... I then added a freesurface method and voila! problem solved. My game runs smoothly as a cat, Cat.
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. garbage collection enabled c++
    By manav in forum C++ Programming
    Replies: 42
    Last Post: 02-15-2008, 01:42 PM
  2. Garbage Collection is not so complicated
    By Nalpdii in forum C Programming
    Replies: 2
    Last Post: 10-08-2007, 12:34 AM
  3. C++ Garbage Collection
    By vaibhav in forum C++ Programming
    Replies: 1
    Last Post: 11-27-2005, 10:26 AM
  4. Garbage Collection
    By Orborde in forum C++ Programming
    Replies: 4
    Last Post: 05-11-2005, 12:18 AM
  5. garbage collection
    By joed in forum C Programming
    Replies: 4
    Last Post: 04-01-2004, 01:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21