mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Report how much memory was requested on OOM.
This commit is contained in:
parent
0f05a1fd63
commit
207cb35c55
1 changed files with 11 additions and 0 deletions
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
#include <new.h>
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4091)
|
||||
#include "client/windows/handler/exception_handler.h"
|
||||
|
@ -105,11 +107,20 @@ std::unique_ptr<ReservedMemoryChunk> ReservedMemory;
|
|||
|
||||
void InstallOperatorNewHandler() {
|
||||
ReservedMemory = std::make_unique<ReservedMemoryChunk>();
|
||||
#ifdef Q_OS_WIN
|
||||
_set_new_handler([](size_t requested) -> int {
|
||||
_set_new_handler(nullptr);
|
||||
ReservedMemory.reset();
|
||||
CrashReports::SetAnnotation("Requested", QString::number(requested));
|
||||
Unexpected("Could not allocate!");
|
||||
});
|
||||
#else // Q_OS_WIN
|
||||
std::set_new_handler([] {
|
||||
std::set_new_handler(nullptr);
|
||||
ReservedMemory.reset();
|
||||
Unexpected("Could not allocate!");
|
||||
});
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
void InstallQtMessageHandler() {
|
||||
|
|
Loading…
Add table
Reference in a new issue