Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Weak pointers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Kohler Markus <kohlerm@b...>
Subject: Re: Weak pointers
> I wonder when Weaks pointers are erased by the GC. As soon
> as it can be or when there is no more memory ? 

I can't speak for caml, but usally when there is no more memory, or the system 
is idle. 

> In the second
> case, does all the weaks pointers that can be erased are erased
> or just enough to allocate new memory. In this case, which are 
> erased, the older or the younger ?
> 
> 
> Is it a good idea to use weak pointers to implement more
> or less a cache ?

 
IMHO not so  a good idea. 
1. Your replacement strategy for the cache will depend on internals of the 
garbage collector. 

2. Also it almost always makes sense to have a cache with a limited size.
 Therefore you have to implement a replacement strategy anyway. 
On machines with virtual memory, the garbage collector ,may always "think" 
that there's more memory left and prefer to grow the process instead of 
reclaiming space.  
Garbage collection in virtual memory can be VERY slow. 

Markus




 

-- 
+----------------------------------------------------------------------------+
| Markus Kohler                          Hewlett-Packard GmbH                |
| Software Engineer                      Network & System Management Division| 
|                                        IT/E Success Team                   |
+----------------------------------------------------------------------------+