Release v0.6.35: reduce resident memory and compact shared dictionaries
This commit is contained in:
+15
-4
@@ -1,4 +1,5 @@
|
||||
#include "app.h"
|
||||
#include <utility>
|
||||
#include "../vendor/json.hpp"
|
||||
#include "../resources/resource.h"
|
||||
#include "ocr.h"
|
||||
@@ -642,7 +643,7 @@ void App::applySettings(const Settings &requested)
|
||||
++inputVersion;
|
||||
if (busy) diagnosticEvent(L"Input context changed: settings applied version=" + std::to_wstring(inputVersion.load()));
|
||||
}
|
||||
// Clear on the worker so the next check reloads edits to dictionary files.
|
||||
// Release the worker's old snapshot; the next check shares the freshly loaded predictor.
|
||||
enqueue([this] { autoCorrector.configure({}, {}); });
|
||||
scheduleHistoryOcr(s);
|
||||
nextSync = std::max(GetTickCount64() + 2000, syncRetryAfter);
|
||||
@@ -703,6 +704,13 @@ void App::resetInput()
|
||||
run.reset();
|
||||
last.reset();
|
||||
}
|
||||
void App::releaseIdleMemory(ULONGLONG now)
|
||||
{
|
||||
expireDiagnostics(now);
|
||||
std::lock_guard lock(stateMutex);
|
||||
// Match the Undo eligibility deadline; never discard an available operation.
|
||||
if (!busy && last && now - last->at > 120000) last.reset();
|
||||
}
|
||||
void App::clearLog(bool previous) { clearDiagnosticLog(previous); }
|
||||
void App::keyboard(const KBDLLHOOKSTRUCT &k, UINT mods)
|
||||
{
|
||||
@@ -1166,9 +1174,11 @@ void App::transform(int command, int snippet)
|
||||
if (!config.autoCorrect || recent.window != target || recent.overflow ||
|
||||
recent.keys.empty() || recent.keys.back() != L' ' || hint < 0)
|
||||
return;
|
||||
autoCorrector.configure(std::filesystem::path(executable()).parent_path() /
|
||||
L"dictionaries",
|
||||
config.autoLanguages);
|
||||
{
|
||||
std::lock_guard lock(stateMutex);
|
||||
if (inputVersion.load() != version) return;
|
||||
autoCorrector.shareDictionaries(autoPredictor);
|
||||
}
|
||||
std::wstring predicted;
|
||||
for (wchar_t key : recent.keys)
|
||||
predicted += key == L' ' ? L' ' : available[hint].at(physicalLayout().code(key));
|
||||
@@ -1883,6 +1893,7 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
||||
case WM_TIMER:
|
||||
if (wp == 6)
|
||||
{
|
||||
app->releaseIdleMemory(GetTickCount64());
|
||||
app->pollSync();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user