# C++ code eat too much memory, growth from 30Mb to 100Mb

**URL:** <https://discourse.gstreamer.org/t/c-code-eat-too-much-memory-growth-from-30mb-to-100mb/1317>\
**Category:** General Discussion\
**Created:** [April 3, 2024, 11:42am UTC](https://discourse.gstreamer.org/t/c-code-eat-too-much-memory-growth-from-30mb-to-100mb/1317 "2024-04-03T11:42:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharov\_am](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@sharov\_am](https://discourse.gstreamer.org/u/sharov_am)\
**Post date:** [April 3, 2024, 11:42am UTC](https://discourse.gstreamer.org/t/c-code-eat-too-much-memory-growth-from-30mb-to-100mb/1317/1 "2024-04-03T11:42:23Z")

</div>

Hi.

Given Ubuntu 22.04 and gst 1.25, there C++ code which capture camera stream, read sample and write mp4 files within configured interval. It starts with 38Mb and then within few hours growth to over 100Mb.  
Why it is so, what we are doing wrong? Maybe we misconfigured something?

Here is pipeline, full source link is below:

```auto
GstElement *create_capture_pipeline() {
    auto *pipeline = gst_parse_launch(
            "rtspsrc buffer_mode=0 name=rtspsrc ! rtph264depay ! h264parse ! tee name=vi"
            " vi. ! splitmuxsink name=sms"
            " vi. ! avdec_h264 ! jpegenc ! tee name=tp2"
            " tp2. ! queue max-size-buffers=10 leaky=2 name=appq"
            " tp2. ! multipartmux boundary=mjpegstream ! tcpserversink host=127.0.0.1 port=1234",
            nullptr);

    return pipeline;

```

Here is full source code – [Share Code Snippets | CodersTool](https://www.coderstool.com/cs/Nz26Cp)

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sharov\_am](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@sharov\_am](https://discourse.gstreamer.org/u/sharov_am)\
**Post date:** [April 24, 2024, 11:56am UTC](https://discourse.gstreamer.org/t/c-code-eat-too-much-memory-growth-from-30mb-to-100mb/1317/2 "2024-04-24T11:56:37Z")

</div>

Hi, any thoughts about the possible issue?

---

<div class="post-metadata">

**Author:** ![Honey\_Patouceul](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/honey_patouceul/32/365_2.png) [@Honey\_Patouceul](https://discourse.gstreamer.org/u/Honey_Patouceul)\
**Post date:** [April 24, 2024, 8:03pm UTC](https://discourse.gstreamer.org/t/c-code-eat-too-much-memory-growth-from-30mb-to-100mb/1317/3 "2024-04-24T20:03:10Z")

</div>

Seems the full source code is no longer available from your link.  
Are you seeing memory usage increase as you’re creating more pipelines ?  
If yes, after you stop a no longer useful pipeline do you call `gst_object_unref(pipeline_pointer)` ?  
If not, not sure but also note that in your example splitmuxsink has no location set.

---

<div class="post-metadata">

**Author:** ![sharov\_am](https://discourse.gstreamer.org/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@sharov\_am](https://discourse.gstreamer.org/u/sharov_am)\
**Post date:** [April 25, 2024, 4:31pm UTC](https://discourse.gstreamer.org/t/c-code-eat-too-much-memory-growth-from-30mb-to-100mb/1317/4 "2024-04-25T16:31:10Z")

</div>

Hi, here is source – [Share Code Snippets | CodersTool](https://www.coderstool.com/cs/Y0nym0)
