| 1007 | |
| 1008 | |
| 1009 | bool CommandLine::CheckValuesAndSetDefaults() { |
| 1010 | if (parfilename.length() == 0) |
| 1011 | { |
| 1012 | std::cerr << "You must specify a Recovery file." << std::endl; |
| 1013 | return false; |
| 1014 | } |
| 1015 | |
| 1016 | |
| 1017 | // Default noise level |
| 1018 | if (noiselevel == nlUnknown) |
| 1019 | { |
| 1020 | noiselevel = nlNormal; |
| 1021 | } |
| 1022 | |
| 1023 | // Default memorylimit of 256MB |
| 1024 | if (memorylimit == 0) |
| 1025 | { |
| 1026 | u64 TotalPhysicalMemory = GetTotalPhysicalMemory(); |
| 1027 | |
| 1028 | if (TotalPhysicalMemory == 0) |
| 1029 | { |
| 1030 | if (noiselevel >= nlDebug) |
| 1031 | std::cout << "[DEBUG] could not detect physical memory" << std::endl; |
| 1032 | |
| 1033 | // Default/error case: |
| 1034 | memorylimit = 256; |
| 1035 | } |
| 1036 | else |
| 1037 | { |
| 1038 | if (noiselevel >= nlDebug) |
| 1039 | std::cout << "[DEBUG] detected physical memory: " << TotalPhysicalMemory << " bytes" << std::endl; |
| 1040 | |
| 1041 | // 1/8th of total physical memory or floor to 256MiB if lower: |
| 1042 | memorylimit = (size_t)(TotalPhysicalMemory / 1048576 / 8); |
| 1043 | if (memorylimit < 256) |
| 1044 | memorylimit = 256; |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | // limit to 1GB on 32-bit platforms to avoid exhausing the addressable memory space |
| 1049 | if (sizeof(uintptr_t) < 8 && memorylimit > 1024) |
| 1050 | memorylimit = 1024; |
| 1051 | |
| 1052 | // convert to megabytes |
| 1053 | memorylimit *= 1048576; |
| 1054 | |
| 1055 | if (noiselevel >= nlDebug) |
| 1056 | { |
| 1057 | std::cout << "[DEBUG] memorylimit: " << memorylimit << " bytes" << std::endl; |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | // Default basepath (uses parfilename) |
| 1062 | if ("" == basepath) |
| 1063 | { |
| 1064 | if (noiselevel >= nlDebug) |
| 1065 | { |
| 1066 | std::cout << "[DEBUG] parfilename: " << parfilename << std::endl; |