Пример #1
0
    /// <summary>
    /// Returns an address of a memory buffer capable of fitting a given size.
    /// </summary>
    /// <returns>True if this is a large object allocation and should be freed with <see cref="FreeLargeObject"/>.</returns>
    public bool Get(int size, out void *address)
    {
        if (_memoryAllocation.CanItemFit(size))
        {
            address = (void *)_memoryAllocation.Address;
            return(false);
        }

        // Note the finalizer inside Allocation.
        // After a period of time, the GC will manually cleanup the old memory.
        _largeObjectAlloc = new Allocation(size);
        address           = (void *)_largeObjectAlloc.Address;
        return(true);
    }