mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 00:07:47 +00:00
Fixed memory leak
This commit is contained in:
parent
f0d576e1b0
commit
2daa7f9fea
2 changed files with 6 additions and 4 deletions
|
@ -201,8 +201,9 @@ void memory_tracking_stop()
|
||||||
uint64_t total_leaks = 0;
|
uint64_t total_leaks = 0;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < N; ++i) {
|
for (uint32_t i = 0; i < N; ++i) {
|
||||||
if (allocations[i].allocated_size) {
|
const TrackedAllocation& t = allocations[i];
|
||||||
total_leaks += allocations[i].allocated_size;
|
if (t.allocated_size) {
|
||||||
|
total_leaks += t.allocated_size;
|
||||||
|
|
||||||
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)] = {};
|
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)] = {};
|
||||||
PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(buffer);
|
PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(buffer);
|
||||||
|
@ -213,9 +214,9 @@ void memory_tracking_stop()
|
||||||
IMAGEHLP_LINE64 line{};
|
IMAGEHLP_LINE64 line{};
|
||||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||||
|
|
||||||
printf("Memory leak detected, %u bytes allocated by thread %u at:\n", allocations[i].allocated_size, allocations[i].thread_id);
|
printf("Memory leak detected, %u bytes allocated at %p by thread %u:\n", t.allocated_size, t.p, t.thread_id);
|
||||||
for (size_t j = 0; j < MAX_FRAMES; ++j) {
|
for (size_t j = 0; j < MAX_FRAMES; ++j) {
|
||||||
const DWORD64 address = reinterpret_cast<DWORD64>(allocations[i].stack_trace[j]);
|
const DWORD64 address = reinterpret_cast<DWORD64>(t.stack_trace[j]);
|
||||||
DWORD64 t1 = 0;
|
DWORD64 t1 = 0;
|
||||||
DWORD t2 = 0;
|
DWORD t2 = 0;
|
||||||
if (SymFromAddr(h, address, &t1, pSymbol) && SymGetLineFromAddr64(h, address, &t2, &line)) {
|
if (SymFromAddr(h, address, &t1, pSymbol) && SymGetLineFromAddr64(h, address, &t2, &line)) {
|
||||||
|
|
|
@ -315,6 +315,7 @@ bool TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::connect_to_peer(Client* client)
|
||||||
|
|
||||||
if (!m_pendingConnections.insert(client->m_addr).second) {
|
if (!m_pendingConnections.insert(client->m_addr).second) {
|
||||||
LOGINFO(6, "there is already a pending connection to this IP, not connecting to " << log::Gray() << static_cast<char*>(client->m_addrString));
|
LOGINFO(6, "there is already a pending connection to this IP, not connecting to " << log::Gray() << static_cast<char*>(client->m_addrString));
|
||||||
|
m_preallocatedClients.push_back(client);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue