File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525
2626#include " config.h"
2727#include < wtf/RAMSize.h>
28+ #include < wtf/text/StringToIntegerConversion.h>
29+ #include < wtf/text/WTFString.h>
2830
2931#include < mutex>
3032
@@ -50,8 +52,35 @@ namespace WTF {
5052static constexpr size_t ramSizeGuess = 512 * MB;
5153#endif
5254
55+ static size_t customRAMSize ()
56+ {
57+ // Syntax: Case insensitive, unit multipliers (M=Mb, K=Kb, <empty>=bytes).
58+ // Example: WPE_RAM_SIZE='500M'
59+
60+ size_t customSize = 0 ;
61+
62+ String s = String::fromLatin1 (getenv (" WPE_RAM_SIZE" ));
63+ if (!s.isEmpty ()) {
64+ String value = s.convertToLowercaseWithoutLocale ();
65+ size_t units = 1 ;
66+ if (value.endsWith (' k' ))
67+ units = KB;
68+ else if (value.endsWith (' m' ))
69+ units = MB;
70+ if (units != 1 )
71+ value = value.substring (0 , value.length () - 1 );
72+ customSize = parseInteger<uint64_t >(value).value_or (0 ) * units;
73+ }
74+
75+ return customSize;
76+ }
77+
5378static size_t computeRAMSize ()
5479{
80+ size_t custom = customRAMSize ();
81+ if (custom)
82+ return custom;
83+
5584#if OS(WINDOWS)
5685 MEMORYSTATUSEX status;
5786 status.dwLength = sizeof (status);
You can’t perform that action at this time.
0 commit comments