Skip to content

Memory leak in rgb2ycbcr #1672

Closed
Closed

Description

@pavanky
    size_t alloc_bytes, alloc_buffers, lock_bytes, lock_buffers;
        for (int i = 0; i < 5; i++) {
            af::array img = randu(100, 100, 3);
            array img2 = af::rgb2ycbcr(img);
            array y = img(span, span, 0);
            array cb = img(span, span, 1);
            array cr = img(span, span, 2);
            af::deviceMemInfo(&alloc_bytes, &alloc_buffers,  
                                 &lock_bytes, &lock_buffers);
            printf("%zu, %zu, %zu, %zu\n",
                   alloc_bytes, alloc_buffers,
                   lock_bytes, lock_buffers);
        }

Activity

  1. added this to the v3.4.2 milestone on Dec 14, 2016
  2. pavanky commented on Dec 14, 2016

    @pavanky
    MemberAuthor

    @9prady9

    This is the portion of the code that is buggy in ycbcr_rgb.cpp

        af_array ch1Temp=0, ch2Temp=0, ch3Temp=0;
        AF_CHECK(af_index(&ch1Temp, in, 4, slice1));
        AF_CHECK(af_index(&ch2Temp, in, 4, slice2));
        AF_CHECK(af_index(&ch3Temp, in, 4, slice3));
        // get Array objects for corresponding channel views                                                                                                                                                             
        Array<T> X = getArray<T>(ch1Temp);
        Array<T> Y = getArray<T>(ch2Temp);
        Array<T> Z = getArray<T>(ch3Temp);

    getArray is not a dereference, it is a shallow copy. So the reference count is incremented. You will need to free ch{1,2,3}Temp.

    A better solution would be to call createSubArray with the right indices instead of calling af_index.

    Can you please fix this along with #1666

  3. shehzan10 commented on Dec 19, 2016

    @shehzan10
    Member

    Fixed in hotfix-3.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions