mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
#ifndef DESKTOP_APP_DISABLE_CRASH_REPORTS
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
#include <new.h>
|
||||||
|
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable:4091)
|
#pragma warning(disable:4091)
|
||||||
#include "client/windows/handler/exception_handler.h"
|
#include "client/windows/handler/exception_handler.h"
|
||||||
|
@ -105,11 +107,20 @@ std::unique_ptr<ReservedMemoryChunk> ReservedMemory;
|
||||||
|
|
||||||
void InstallOperatorNewHandler() {
|
void InstallOperatorNewHandler() {
|
||||||
ReservedMemory = std::make_unique<ReservedMemoryChunk>();
|
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([] {
|
||||||
std::set_new_handler(nullptr);
|
std::set_new_handler(nullptr);
|
||||||
ReservedMemory.reset();
|
ReservedMemory.reset();
|
||||||
Unexpected("Could not allocate!");
|
Unexpected("Could not allocate!");
|
||||||
});
|
});
|
||||||
|
#endif // Q_OS_WIN
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallQtMessageHandler() {
|
void InstallQtMessageHandler() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue