Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/11/17 20:07:13 (8 years ago)
Author:
pkimmesw
Message:

#2665 PooledPushProgram reduces memory usage and increases performance

Location:
branches/PushGP/HeuristicLab.PushGP/TestPooling/Pool
Files:
2 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/TestPooling/Pool/ManagedPoolProvider.cs

    r14745 r14746  
    88  using System.Runtime.Serialization.Formatters.Binary;
    99
     10  public interface IManagedPool<T> : IDisposable where T : class {
     11    T Get();
     12  }
     13
    1014  public class ManagedPoolProvider<T> where T : class {
    1115    private readonly ConcurrentStack<T[]> partitions = new ConcurrentStack<T[]>();
    1216    private readonly ObjectPool<IManagedPool<T>> managedPools;
    1317    private T[] DummyPartition;
     18
    1419    public readonly int PartitionSize;
     20    public readonly int MaxParitionCount;
     21    public const int DefaultMaxInstanceCount = 16384;
    1522
    16     public int InstanceCount { get { return partitions.Count * PartitionSize; } }
     23    public ManagedPoolProvider(int partitionSize, int maxPartitionCount = -1) {
     24      PartitionSize = partitionSize;
    1725
    18     public ManagedPoolProvider(int partitionSize) {
    19       PartitionSize = partitionSize;
     26      if (maxPartitionCount <= 0) {
     27        MaxParitionCount = DefaultMaxInstanceCount / PartitionSize;
     28      }
     29
    2030      managedPools = new ObjectPool<IManagedPool<T>>(() => new ManagedPool2<T>(this));
    2131    }
     
    2737      }
    2838    }
     39
     40    public int InstanceCount { get { return partitions.Count * PartitionSize; } }
    2941
    3042    public void ReleasePartitions(params T[][] partition) {
Note: See TracChangeset for help on using the changeset viewer.