[prev in list] [next in list] [prev in thread] [next in thread] 

List:       usrp-users
Subject:    Re: [USRP-users] UHD and Memory leak
From:       Marcus_Müller via USRP-users <usrp-users () lists ! ettus ! com>
Date:       2016-01-29 8:29:53
Message-ID: 56AB2301.6020202 () ettus ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi John,
we're actively investigating this, but haven't been able to reproduce
your specific rate (or at least the same linear behaviour) of memory
usage growth; we do indeed see an increase of memory usage over time,
but that might as well be libc doing its memory allocations prefering
speed over minimized usage.
As I said, still investigating.

Best regards,
Marcus

On 01/29/2016 05:02 AM, john liu via USRP-users wrote:
> Hi,Martin,
>          To the question, do you have some conclusions or suggestions?
> Cheers,
> John
>
> On Tue, Dec 29, 2015 at 10:17 AM, Martin Braun <martin.braun@ettus.com
> <mailto:martin.braun@ettus.com>> wrote:
>
>     Thanks, John,
>
>     I hope we can find time soon to look into this. Thanks for sending
>     this!
>
>     Cheers,
>     Martin
>
>     On 27.12.2015 17:15, john liu wrote:
>     > hi,martin,
>     >  I am so sorry to reply  you so late.
>     >   and thank you for reply.
>     >  we take frequency hopping in vs2010+windows7,and we do nothing
>     > but frequency hopping.
>     > here is our test code:
>     >
>     > namespace po = boost::program_options;
>     >
>     > long arryArryAntParam[][4] = {
>     > {101700000, 8000000, 16000000, 20},
>     > //{102600000, 300000, 400000, 20}
>     > };
>     >
>     > int main(){
>     > //unsigned int x1 = 8000000;
>     > //unsigned int x2 = 1024;
>     > //long long l1 = (long long)x1 * x2;
>     > //std::cout << l1 << std::endl;
>     > //system("pause");
>     > uhd::set_thread_priority_safe();
>     >
>     > //variables to be set by po
>     > std::string args(""), subdev("A:A");
>     > size_t num_bins = 1024;
>     > float ref_lvl = 0.0, dyn_rng = 100.0;
>     >
>     > //create a usrp device
>     > std::cout << std::endl;
>     > std::cout << boost::format("Creating the usrp device with: %s...") %
>     > args << std::endl;
>     > uhd::usrp::multi_usrp::sptr usrp =
>     uhd::usrp::multi_usrp::make(args);
>     >
>     > //Lock mboard clocks
>     > usrp->set_clock_source("internal");
>     >
>     > //always select the subdevice first, the channel mapping affects the
>     > other settings
>     > usrp->set_rx_subdev_spec(subdev);
>     >
>     > std::cout << boost::format("Using Device: %s") %
>     usrp->get_pp_string()
>     > << std::endl;
>     >
>     > long freq, bw, rate, gain;
>     > for (int i = 0; true; i++)
>     > {
>     > freq = arryArryAntParam[i%1][0];
>     > bw = arryArryAntParam[i%1][1];
>     > rate = arryArryAntParam[i%1][2];
>     > gain = arryArryAntParam[i%1][3];
>     >
>     > //std::cout << boost::format("Setting RX Freq: %f MHz...") %
>     (freq/1e6)
>     > << std::endl;
>     > uhd::tune_request_t tune_request(freq);
>     > //tune_request.args = uhd::device_addr_t("mode_n=integer");
>     > usrp->set_rx_freq(tune_request);
>     > //std::cout << boost::format("Actual RX Freq: %f MHz...") %
>     > (usrp->get_rx_freq()/1e6) << std::endl << std::endl;
>     >
>     > //set the analog frontend filter bandwidth
>     > //std::cout << boost::format("Setting RX Bandwidth: %f MHz...") %
>     > (bw/1e6) << std::endl;
>     > usrp->set_rx_bandwidth(bw);
>     > //std::cout << boost::format("Actual RX Bandwidth: %f MHz...") %
>     > (usrp->get_rx_bandwidth()/1e6) << std::endl << std::endl;
>     >
>     > //std::cout << boost::format("Setting RX Rate: %f Msps...") %
>     (rate/1e6)
>     > << std::endl;
>     > usrp->set_rx_rate(rate);
>     > //std::cout << boost::format("Actual RX Rate: %f Msps...") %
>     > (usrp->get_rx_rate()/1e6) << std::endl << std::endl;
>     >
>     > //set the rf gain
>     > //std::cout << boost::format("Setting RX Gain: %f dB...") % gain <<
>     > std::endl;
>     > usrp->set_rx_gain(gain);
>     > //std::cout << boost::format("Actual RX Gain: %f dB...") %
>     > usrp->get_rx_gain() << std::endl << std::endl;
>     >
>     > boost::this_thread::sleep(boost::posix_time::millisec(1));
>     //allow for
>     > some setup time
>     >
>     > #if 0
>     > //Check Ref and LO Lock detect
>     > std::vector<std::string> sensor_names;
>     > sensor_names = usrp->get_rx_sensor_names(0);
>     > if (std::find(sensor_names.begin(), sensor_names.end(),
>     "lo_locked") !=
>     > sensor_names.end()) {
>     > uhd::sensor_value_t lo_locked = usrp->get_rx_sensor("lo_locked",0);
>     > std::cout << boost::format("Checking RX: %s ...") %
>     > lo_locked.to_pp_string() << std::endl;
>     > UHD_ASSERT_THROW(lo_locked.to_bool());
>     > }
>     >
>     > //create a receive streamer
>     > uhd::stream_args_t stream_args("fc32"); //complex floats
>     > uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
>     >
>     > //allocate recv buffer and metatdata
>     > uhd::rx_metadata_t md;
>     > std::vector<std::complex<float> > buff(num_bins);
>     >
>     > uhd::stream_cmd_t
>     > stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
>     > stream_cmd.num_samps = num_bins;
>     > stream_cmd.stream_now = true;
>     > stream_cmd.time_spec = uhd::time_spec_t();
>     > rx_stream->issue_stream_cmd(stream_cmd);
>     >
>     //rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
>     >
>     > while (true){
>     > //read a buffer's worth of samples every iteration
>     > size_t num_rx_samps = rx_stream->recv(
>     > &buff.front(), buff.size(), md
>     > );
>     > if (num_rx_samps != buff.size()) continue;
>     >
>     > //calculate the dft and create the ascii art frame
>     > acsii_art_dft::log_pwr_dft_type lpdft(
>     > acsii_art_dft::log_pwr_dft(&buff.front(), num_rx_samps)
>     > );
>     >
>     > //std::string frame = acsii_art_dft::dft_to_plot(
>     > //lpdft, 100, 50,
>     > //usrp->get_rx_rate(),
>     > //usrp->get_rx_freq(),
>     > //dyn_rng, ref_lvl
>     > //);
>     >
>     > //printf("%s", frame.c_str());
>     > break;
>     > }
>     >
>     >
>     rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
>     > #endif
>     > //boost::this_thread::sleep(boost::posix_time::millisec(1));
>     //allow for
>     > some setup time
>     > }
>     >
>     > std::cout << std::endl << "Done!" << std::endl << std::endl;
>     >
>     > return EXIT_SUCCESS;
>     > }
>     > thank you !
>     > John
>     >
>     >
>     > John,
>     >
>     > it's entirely possible that there's a memory leak in UHD, but in
>     order
>     > to track that down we'd need some more info on what you're
>     doing. Can
>     > you maybe even post some code snippets of what you're doing, or give
>     > some more description of your code?
>     >
>     > Cheers,
>     > Martin
>     >
>     > On 21.12.2015 19:30, john liu via USRP-users wrote:
>     >> Dear all,
>     >>            we are using usrp B210 to do spectrum scanning,and
>     we take
>     >> frequency hopping method to achieve  it,and the frequency
>     hopping step
>     >> is 8M.But  every time the frequency change,the memory will be
>     up 4K?Can
>     >> you give some advice?
>     >> Would really appreciate your reply in advance.
>     >> Thank you
>     >> John
>     >>
>
>
>
>
> _______________________________________________
> USRP-users mailing list
> USRP-users@lists.ettus.com
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com


[Attachment #5 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi John,<br>
    we're actively investigating this, but haven't been able to
    reproduce your specific rate (or at least the same linear behaviour)
    of memory usage growth; we do indeed see an increase of memory usage
    over time, but that might as well be libc doing its memory
    allocations prefering speed over minimized usage. <br>
    As I said, still investigating.<br>
    <br>
    Best regards,<br>
    Marcus<br>
    <br>
    <div class="moz-cite-prefix">On 01/29/2016 05:02 AM, john liu via
      USRP-users wrote:<br>
    </div>
    <blockquote
cite="mid:CAF6NnTKpKmXUMZ=3EOufXpseLZyaLcbO+b=AxPJ9HCdWgfNfww@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,Martin,
        <div>         To the question, do you have some conclusions or
          suggestions?</div>
        <div>Cheers,</div>
        <div>John</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Tue, Dec 29, 2015 at 10:17 AM,
          Martin Braun <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:martin.braun@ettus.com" \
target="_blank">martin.braun@ettus.com</a>&gt;</span>  wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks,
            John,<br>
            <br>
            I hope we can find time soon to look into this. Thanks for
            sending this!<br>
            <br>
            Cheers,<br>
            Martin<br>
            <div class="HOEnZb">
              <div class="h5"><br>
                On 27.12.2015 17:15, john liu wrote:<br>
                &gt; hi,martin,<br>
                &gt;  I am so sorry to reply  you so late.<br>
                &gt;   and thank you for reply.<br>
                &gt;  we take frequency hopping in vs2010+windows7,and
                we do nothing<br>
                &gt; but frequency hopping.<br>
                &gt; here is our test code:<br>
                &gt;<br>
                &gt; namespace po = boost::program_options;<br>
                &gt;<br>
                &gt; long arryArryAntParam[][4] = {<br>
                &gt; {101700000, 8000000, 16000000, 20},<br>
                &gt; //{102600000, 300000, 400000, 20}<br>
                &gt; };<br>
                &gt;<br>
                &gt; int main(){<br>
                &gt; //unsigned int x1 = 8000000;<br>
                &gt; //unsigned int x2 = 1024;<br>
                &gt; //long long l1 = (long long)x1 * x2;<br>
                &gt; //std::cout &lt;&lt; l1 &lt;&lt; std::endl;<br>
                &gt; //system("pause");<br>
                &gt; uhd::set_thread_priority_safe();<br>
                &gt;<br>
                &gt; //variables to be set by po<br>
                &gt; std::string args(""), subdev("A:A");<br>
                &gt; size_t num_bins = 1024;<br>
                &gt; float ref_lvl = 0.0, dyn_rng = 100.0;<br>
                &gt;<br>
                &gt; //create a usrp device<br>
                &gt; std::cout &lt;&lt; std::endl;<br>
                &gt; std::cout &lt;&lt; boost::format("Creating the usrp
                device with: %s...") %<br>
                &gt; args &lt;&lt; std::endl;<br>
                &gt; uhd::usrp::multi_usrp::sptr usrp =
                uhd::usrp::multi_usrp::make(args);<br>
                &gt;<br>
                &gt; //Lock mboard clocks<br>
                &gt; usrp-&gt;set_clock_source("internal");<br>
                &gt;<br>
                &gt; //always select the subdevice first, the channel
                mapping affects the<br>
                &gt; other settings<br>
                &gt; usrp-&gt;set_rx_subdev_spec(subdev);<br>
                &gt;<br>
                &gt; std::cout &lt;&lt; boost::format("Using Device:
                %s") % usrp-&gt;get_pp_string()<br>
                &gt; &lt;&lt; std::endl;<br>
                &gt;<br>
                &gt; long freq, bw, rate, gain;<br>
                &gt; for (int i = 0; true; i++)<br>
                &gt; {<br>
                &gt; freq = arryArryAntParam[i%1][0];<br>
                &gt; bw = arryArryAntParam[i%1][1];<br>
                &gt; rate = arryArryAntParam[i%1][2];<br>
                &gt; gain = arryArryAntParam[i%1][3];<br>
                &gt;<br>
                &gt; //std::cout &lt;&lt; boost::format("Setting RX
                Freq: %f MHz...") % (freq/1e6)<br>
                &gt; &lt;&lt; std::endl;<br>
                &gt; uhd::tune_request_t tune_request(freq);<br>
                &gt; //tune_request.args =
                uhd::device_addr_t("mode_n=integer");<br>
                &gt; usrp-&gt;set_rx_freq(tune_request);<br>
                &gt; //std::cout &lt;&lt; boost::format("Actual RX Freq:
                %f MHz...") %<br>
                &gt; (usrp-&gt;get_rx_freq()/1e6) &lt;&lt; std::endl
                &lt;&lt; std::endl;<br>
                &gt;<br>
                &gt; //set the analog frontend filter bandwidth<br>
                &gt; //std::cout &lt;&lt; boost::format("Setting RX
                Bandwidth: %f MHz...") %<br>
                &gt; (bw/1e6) &lt;&lt; std::endl;<br>
                &gt; usrp-&gt;set_rx_bandwidth(bw);<br>
                &gt; //std::cout &lt;&lt; boost::format("Actual RX
                Bandwidth: %f MHz...") %<br>
                &gt; (usrp-&gt;get_rx_bandwidth()/1e6) &lt;&lt;
                std::endl &lt;&lt; std::endl;<br>
                &gt;<br>
                &gt; //std::cout &lt;&lt; boost::format("Setting RX
                Rate: %f Msps...") % (rate/1e6)<br>
                &gt; &lt;&lt; std::endl;<br>
                &gt; usrp-&gt;set_rx_rate(rate);<br>
                &gt; //std::cout &lt;&lt; boost::format("Actual RX Rate:
                %f Msps...") %<br>
                &gt; (usrp-&gt;get_rx_rate()/1e6) &lt;&lt; std::endl
                &lt;&lt; std::endl;<br>
                &gt;<br>
                &gt; //set the rf gain<br>
                &gt; //std::cout &lt;&lt; boost::format("Setting RX
                Gain: %f dB...") % gain &lt;&lt;<br>
                &gt; std::endl;<br>
                &gt; usrp-&gt;set_rx_gain(gain);<br>
                &gt; //std::cout &lt;&lt; boost::format("Actual RX Gain:
                %f dB...") %<br>
                &gt; usrp-&gt;get_rx_gain() &lt;&lt; std::endl &lt;&lt;
                std::endl;<br>
                &gt;<br>
                &gt;
                boost::this_thread::sleep(boost::posix_time::millisec(1));
                //allow for<br>
                &gt; some setup time<br>
                &gt;<br>
                &gt; #if 0<br>
                &gt; //Check Ref and LO Lock detect<br>
                &gt; std::vector&lt;std::string&gt; sensor_names;<br>
                &gt; sensor_names = usrp-&gt;get_rx_sensor_names(0);<br>
                &gt; if (std::find(sensor_names.begin(),
                sensor_names.end(), "lo_locked") !=<br>
                &gt; sensor_names.end()) {<br>
                &gt; uhd::sensor_value_t lo_locked =
                usrp-&gt;get_rx_sensor("lo_locked",0);<br>
                &gt; std::cout &lt;&lt; boost::format("Checking RX: %s
                ...") %<br>
                &gt; lo_locked.to_pp_string() &lt;&lt; std::endl;<br>
                &gt; UHD_ASSERT_THROW(lo_locked.to_bool());<br>
                &gt; }<br>
                &gt;<br>
                &gt; //create a receive streamer<br>
                &gt; uhd::stream_args_t stream_args("fc32"); //complex
                floats<br>
                &gt; uhd::rx_streamer::sptr rx_stream =
                usrp-&gt;get_rx_stream(stream_args);<br>
                &gt;<br>
                &gt; //allocate recv buffer and metatdata<br>
                &gt; uhd::rx_metadata_t md;<br>
                &gt; std::vector&lt;std::complex&lt;float&gt; &gt;
                buff(num_bins);<br>
                &gt;<br>
                &gt; uhd::stream_cmd_t<br>
                &gt;
                stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);<br>
                &gt; stream_cmd.num_samps = num_bins;<br>
                &gt; stream_cmd.stream_now = true;<br>
                &gt; stream_cmd.time_spec = uhd::time_spec_t();<br>
                &gt; rx_stream-&gt;issue_stream_cmd(stream_cmd);<br>
                &gt;
//rx_stream-&gt;issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);<br>
  &gt;<br>
                &gt; while (true){<br>
                &gt; //read a buffer's worth of samples every iteration<br>
                &gt; size_t num_rx_samps = rx_stream-&gt;recv(<br>
                &gt; &amp;buff.front(), buff.size(), md<br>
                &gt; );<br>
                &gt; if (num_rx_samps != buff.size()) continue;<br>
                &gt;<br>
                &gt; //calculate the dft and create the ascii art frame<br>
                &gt; acsii_art_dft::log_pwr_dft_type lpdft(<br>
                &gt; acsii_art_dft::log_pwr_dft(&amp;buff.front(),
                num_rx_samps)<br>
                &gt; );<br>
                &gt;<br>
                &gt; //std::string frame = acsii_art_dft::dft_to_plot(<br>
                &gt; //lpdft, 100, 50,<br>
                &gt; //usrp-&gt;get_rx_rate(),<br>
                &gt; //usrp-&gt;get_rx_freq(),<br>
                &gt; //dyn_rng, ref_lvl<br>
                &gt; //);<br>
                &gt;<br>
                &gt; //printf("%s", frame.c_str());<br>
                &gt; break;<br>
                &gt; }<br>
                &gt;<br>
                &gt;
rx_stream-&gt;issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);<br>
                &gt; #endif<br>
                &gt;
                //boost::this_thread::sleep(boost::posix_time::millisec(1));
                //allow for<br>
                &gt; some setup time<br>
                &gt; }<br>
                &gt;<br>
                &gt; std::cout &lt;&lt; std::endl &lt;&lt; "Done!"
                &lt;&lt; std::endl &lt;&lt; std::endl;<br>
                &gt;<br>
                &gt; return EXIT_SUCCESS;<br>
                &gt; }<br>
                &gt; thank you !<br>
                &gt; John<br>
                &gt;<br>
                &gt;<br>
                &gt; John,<br>
                &gt;<br>
                &gt; it's entirely possible that there's a memory leak
                in UHD, but in order<br>
                &gt; to track that down we'd need some more info on what
                you're doing. Can<br>
                &gt; you maybe even post some code snippets of what
                you're doing, or give<br>
                &gt; some more description of your code?<br>
                &gt;<br>
                &gt; Cheers,<br>
                &gt; Martin<br>
                &gt;<br>
                &gt; On 21.12.2015 19:30, john liu via USRP-users wrote:<br>
                &gt;&gt; Dear all,<br>
                &gt;&gt;            we are using usrp B210 to do
                spectrum scanning,and we take<br>
                &gt;&gt; frequency hopping method to achieve  it,and the
                frequency hopping step<br>
                &gt;&gt; is 8M.But  every time the frequency change,the
                memory will be up 4K?Can<br>
                &gt;&gt; you give some advice?<br>
                &gt;&gt; Would really appreciate your reply in advance.<br>
                &gt;&gt; Thank you<br>
                &gt;&gt; John<br>
                &gt;&gt;<br>
                <br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
USRP-users mailing list
<a class="moz-txt-link-abbreviated" \
href="mailto:USRP-users@lists.ettus.com">USRP-users@lists.ettus.com</a> <a \
class="moz-txt-link-freetext" \
href="http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com">http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com</a>
 </pre>
    </blockquote>
    <br>
  </body>
</html>



_______________________________________________
USRP-users mailing list
USRP-users@lists.ettus.com
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic