Skip to content

Commit 7451e55

Browse files
committed
Added MaxProfileSize to the ResourceLimits.
1 parent 3ed7a34 commit 7451e55

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

src/Magick.NET.Core/IResourceLimits.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public interface IResourceLimits
3636
/// </summary>
3737
ulong MaxMemoryRequest { get; set; }
3838

39+
/// <summary>
40+
/// Gets or sets the max size of a profile in bytes that can be added to the image.
41+
/// </summary>
42+
ulong MaxProfileSize { get; set; }
43+
3944
/// <summary>
4045
/// Gets or sets the pixel cache limit in bytes. Once this memory limit is exceeded, all subsequent pixels cache
4146
/// operations are to/from disk. The default value of this is 50% of the available memory on the machine in 64-bit mode.

src/Magick.NET/Native/ResourceLimits.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ private partial class NativeResourceLimits
3232
[Throws]
3333
public static partial void MaxMemoryRequest_Set(ulong value);
3434

35+
public static partial ulong MaxProfileSize_Get();
36+
37+
[Throws]
38+
public static partial void MaxProfileSize_Set(ulong value);
39+
3540
public static partial ulong Memory_Get();
3641

3742
public static partial void Memory_Set(ulong value);

src/Magick.NET/ResourceLimits.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ public static ulong MaxMemoryRequest
5656
set => NativeResourceLimits.MaxMemoryRequest_Set(value);
5757
}
5858

59+
/// <summary>
60+
/// Gets or sets the max size of a profile in bytes that can be added to the image.
61+
/// </summary>
62+
public static ulong MaxProfileSize
63+
{
64+
get => NativeResourceLimits.MaxProfileSize_Get();
65+
set => NativeResourceLimits.MaxProfileSize_Set(value);
66+
}
67+
5968
/// <summary>
6069
/// Gets or sets the pixel cache limit in bytes. Once this memory limit is exceeded, all subsequent pixels cache
6170
/// operations are to/from disk. The default value of this is 50% of the available memory on the machine in 64-bit mode.
@@ -151,6 +160,15 @@ ulong IResourceLimits.MaxMemoryRequest
151160
set => MaxMemoryRequest = value;
152161
}
153162

163+
/// <summary>
164+
/// Gets or sets the max size of a profile in bytes that can be added to the image.
165+
/// </summary>
166+
ulong IResourceLimits.MaxProfileSize
167+
{
168+
get => MaxProfileSize;
169+
set => MaxProfileSize = value;
170+
}
171+
154172
/// <summary>
155173
/// Gets or sets the pixel cache limit in bytes. Once this memory limit is exceeded, all subsequent pixels cache
156174
/// operations are to/from disk. The default value of this is 50% of the available memory on the machine in 64-bit mode.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using ImageMagick;
5+
using Xunit;
6+
7+
namespace Magick.NET.Tests;
8+
9+
public partial class ResourceLimitsTests
10+
{
11+
[Collection(nameof(RunTestsSeparately))]
12+
public class TheMaxProfileSizePropertry
13+
{
14+
[Fact]
15+
public void ShouldHaveTheCorrectValue()
16+
{
17+
Assert.Equal((ulong)long.MaxValue, ResourceLimits.MaxProfileSize);
18+
}
19+
20+
[Fact]
21+
public void ShouldReturnTheCorrectValueWhenChanged()
22+
{
23+
var maxProfileSize = ResourceLimits.MaxProfileSize;
24+
25+
ResourceLimits.MaxProfileSize = 42U;
26+
Assert.Equal(42U, ResourceLimits.MaxProfileSize);
27+
ResourceLimits.MaxProfileSize = maxProfileSize;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)