|
From: | Moses Browne Mwakyanjala |
Subject: | [Discuss-gnuradio] Recurring memory leak problems with iterative decoding [ GNU Radio 3.7.11.1] |
Date: | Mon, 29 Apr 2019 21:30:41 +0200 |
set_msg_handler(d_in_port, boost::bind(&decodeLDPC_impl::decode, this ,_1) );
ccsdsLDPC = new ldpc(d_file);
void
decodeLDPC_impl::decode(pmt::pmt_t msg)
{
pmt::pmt_t meta(pmt::car(msg));
pmt::pmt_t bits(pmt::cdr(msg));
std::vector<float> softBits = pmt::f32vector_elements(bits);
// LDPC Decoding
std::vector<unsigned char> decodedBits = (*this.*ldpcDecode)(softBits);
if(d_pack)
{
uint8_t *decoded_u8 = (uint8_t *)malloc(sizeof(uint8_t)*decodedBits.size()/8);
for(int i=0; i<decodedBits.size()/8; i++)
{
decoded_u8[i] = 0;
for(int j=0; j<8; j++)
{
decoded_u8[i] |= decodedBits[i*8+j]?(0x80>>j):0;
}
}
// Publishing data
pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL,pmt::make_blob(decoded_u8,decodedBits.size()/8)));
message_port_pub(d_out_port, pdu);
free(decoded_u8);
}
else
{
// Publishing data
pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL,pmt::make_blob(decodedBits.data(),decodedBits.size())));
message_port_pub(d_out_port, pdu);
}
decodedBits.clear();
softBits.clear();
}
My question is what could possibly be the cause of the memory leak I experience? There are no memory leaks when the class is used outside GNU Radio. To add more confusion, I experienced the same situation when I was working with another iterative decoder for Turbo code (only 10 iterations). The code was able to run smoothly in a C++ application but experienced memory leaks in GNU Radio.I also have one question regarding buffering in GNU Radio. Since iterative decoding with a large number of iterations and large block sizes takes time to complete, the input pmt data that is not consumed immediately will have to be stored somewhere. Is that the case? Could that be the reason for the memory leak?Regards,Moses.
decodeLDPC_impl.cc
Description: Text Data
decodeLDPC_impl.h
Description: Text Data
ldpc.h
Description: Text Data
ldpc.cpp
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |