DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage Class / GetCacheSize Method
Type of Cache of interest, default value is DicomObjects.Enums.CacheTypes.All
Example

In This Topic
    GetCacheSize Method (DicomImage)
    In This Topic
    Get cache size used by DicomObjects for the image - useful to help decide when to call ClearCaches method
    Syntax
    'Declaration
     
    
    Public Function GetCacheSize( _
       ByVal cacheType As CacheTypes _
    ) As System.Long
    public System.long GetCacheSize( 
       CacheTypes cacheType
    )

    Parameters

    cacheType
    Type of Cache of interest, default value is DicomObjects.Enums.CacheTypes.All

    Return Value

    number of bytes cached by DicomObjects
    Example
    DicomImage image = new DicomImage("your_dicom_image.dcm");
    var cacheSize = image.GetCacheSize(CacheTypes.All);
                        
    // Example Scenario: Playing a video in DicomViewer:
    // For each frame, check Cache Size and clear it if value is too high
    image = Viewer.CurrentImage; // Current DicomImage in the Viewer
    var cacheSize = image.GetCacheSize(CacheTypes.All);
    int maxCacheBeforeClear = 5000000;
    if (cacheSize >= maxCacheBeforeClear) 
        image.ClearCaches();
        
    // Alternatively: Use the current images CacheMode
    image.CacheMode = CacheTypes.All;
    var cacheSize = image.GetCacheSize(image.CacheMode);
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also