AllocatedDiskBytesCount
Cache.AllocatedDiskBytesCount property
获取分配的磁盘字节数。
public static long AllocatedDiskBytesCount { get; }
适当的价值
分配的磁盘字节数。
例子
这个例子演示了 Aspose.Imaging.Cache 的使用
[C#]
// 默认情况下,缓存文件夹设置为用户的本地临时目录。
// 您还可以指定另一个缓存文件夹而不是默认值,如下所示:
// Cache.CacheFolder = @"D:\\MyTemp";
// 自动模式灵活高效
Aspose.Imaging.Cache.CacheType = Aspose.Imaging.CacheType.Auto;
// 默认值为0,表示没有上限
Aspose.Imaging.Cache.MaxDiskSpaceForCache = 1073741824; // 1 GB
Aspose.Imaging.Cache.MaxMemoryForCache = 1073741824; // 1 GB
// 不建议更改以下属性,因为它可能会极大地影响性能
Aspose.Imaging.Cache.ExactReallocateOnly = false;
// 您可以随时检查当前分配给内存或磁盘的字节数
// 通过检查以下属性进行缓存
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
// 做一些图像处理如下
Aspose.Imaging.ImageOptions.GifOptions options = new Aspose.Imaging.ImageOptions.GifOptions();
options.Palette = new ColorPalette(new Aspose.Imaging.Color[] { Aspose.Imaging.Color.Red, Aspose.Imaging.Color.Blue, Aspose.Imaging.Color.Black, Aspose.Imaging.Color.White });
options.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(options, 100, 100))
{
Aspose.Imaging.Color[] pixels = new Aspose.Imaging.Color[10000];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Aspose.Imaging.Color.White;
}
image.SavePixels(image.Bounds, pixels);
// 执行上述代码后,内存中将分配 40000 字节。
long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}
// 分配属性可用于检查是否所有 Aspose.Imaging 对象都被正确处理。
// 如果您忘记对某个对象调用 dispose,则缓存值将不同于 0。
l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
也可以看看
- class Cache
- 命名空间 Aspose.Imaging
- 部件 Aspose.Imaging