[Gc] Beginer with GC.

Hans Boehm Hans.Boehm at hp.com
Mon Jan 24 21:09:53 PST 2005


Your example looks fine to me.  You should keep in mind though that the
collector normally only runs every once in a while, when it decides that
you would otherwise need too much heap space.   If you allocate a single
object, it normally wouldn't even run, and your object would just
go away at process termination, as if you had just called malloc.

GC_MALLOC basically behaves like malloc:  It allocates space, but it does
not invoke a constructor.  (GC_MALLOC does initialize the object to all
zeroes, unlike malloc.)

The license was designed to allow commercial use.

Hans

On Mon, 24 Jan 2005, Renato Tegon Forti wrote:

> Hi All,
>
> I m beginer with GC, and I have two doubts:
>
>
>
> 1 - Can I use this GC in my commercial applications?
>
> 2 - This simple use is only alloc Objs witch:
>
>
>
> GC_MALLOC
>
>
>
> //...
>
> Ex:
>
> class test
>
> {
>
> public:
>
>       int x;
>
>       int y[10][10];
>
> };
>
>
>
> int _tmain(int argc, _TCHAR* argv[])
>
> {
>
>       int i;
>
>
>
>       GC_INIT();  /* Optional on Linux/X86; see below.  */
>
>
>
>       for (int i = 0; i < 10000000; i++)
>
>       {
>
>             //char* p = new char;
>
>             test* p = (test*) GC_MALLOC(sizeof(test *));
>
>             //test* p = new test();
>
>             //delete p;
>
>
>
>       }
>
>
>
>
>
>       return 0;
>
> }
>
> //...
>
>
>
> It is all that I need?
>
>
>
> Thanks to all.
>
>
>
>
>
>


More information about the Gc mailing list