Closed rishadbaniya closed 2 years ago
A debug build showed much more details :
All i found out was the loop where i used getMessage is causing a lot of allocations, a lot in a loop
Found out that in getMessage(), the KEEP_ALIVE message was getting constantly allocated on the heap as messages.push(msg)
Not clearing the buffer before returning Message::KEEP_ALIVE
as causing Message::KEEP_ALIVE
to be pushed continously,
if bytes.len() == 0 {
// If the buffer is empty then it means there is no message
None
} else if bytes.len() == 4 {
// TODO : Check if the length is (0_u32) as well
Some(Ok(Message::KEEP_ALIVE))
} else {
let pstr_len = bytes[0];
if pstr_len == 19u8 {
clearing the buffer before returning Message::KEEP_ALIVE
can fix this issue
f29ef8a8a60f19c3785a0abb041d6526ec75dcdb fixes the memory allocation
A huge heap consumption was seen, around 3.8 gigs at the end of the program, need to figure out what caused this leak