Changes between Version 19 and Version 20 of Processing/lagdevelopersfaq
- Timestamp:
- Jul 11, 2012, 5:44:31 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Processing/lagdevelopersfaq
v19 v20 239 239 240 240 Upon creation of the quadtree the user specifies a maximum number of points to be held in memory. Whenever a new bucket is created inside {{{PointBucket::cache()}}} the {{{CacheMinder::updateCache(int requestSize, PointBucket* pointBucket, bool force)}}} method is called with {{{requestSize}}} parameter equal to the number of points that will be held in that bucket. This number is then added to the value of {{{CacheMinder::cacheUsed}}} variable and compared to {{{CacheMinder::totalCache}}}, which is equal to maximum number of points that can be held in memory. If the sum of the to is smaller then maxim cache size the {{{cachUsed}}} variable is updated and a pointer to the bucket is added to the queue ({{{std::deque}}}) of cached buckets. If total amount of cache requested is greater then allowed maximum the buckets are taken from the front of the queue and uncached until there's enough space for the new bucket. (A note here: the {{{force}}} variable in {{{updateCache()}}} method is actually obsolete as it's always set to true). \\ \\ 241 When a bucket needs to be uncached, because there is no more room for new buckets in memory, {{{PointBucket::uncache()}}} method is called which serializes the bucket by compressing it and writes it to a file. T wolso compression is used for this together with two static variables to reduce the memory overhead. The serialization code looks like this:241 When a bucket needs to be uncached, because there is no more room for new buckets in memory, {{{PointBucket::uncache()}}} method is called which serializes the bucket by compressing it and writes it to a file. The lso compression is used for this together with two static variables to reduce the memory overhead. The serialization code looks like this: 242 242 243 243 {{{ … … 258 258 }}} 259 259 260 Once the data has been written, the bucket is deleted from memory and {{{CacheMinder:: update_cache()}}} method gets called with negative {{{requestSize}}} to update the amount of used cache. \\ \\260 Once the data has been written, the bucket is deleted from memory and {{{CacheMinder::releaseCache()}}} method gets called with negative {{{requestSize}}} to update the amount of used cache. \\ \\ 261 261 If a {{{setPoint()}}} or {{{getPoint()}}} method is called on an uncached bucked it is simply re-created from the file and {{{CacheMinder::updateCache()}}} is called to reflect this change. 262 262