Skip to content

Unmanaged memory not released after using SearchStreamAsync with asynchronous response callback in v24.1.0 #627

@hetavi-chaudhary

Description

@hetavi-chaudhary

Describe the bug:

After upgrading to Google.Ads.GoogleAds v24.1.0, we started using the new asynchronous response callback of the SearchStreamAsync method.
However, we’ve observed that unmanaged memory usage is not released even after the entire process completes.

From memory profiling, it appears that the unmanaged memory is held by components within the Google.Ads.GoogleAds namespaces.

Steps to Reproduce:
Below is a simplified version of our usage pattern:

await googleAdsService.GetGoogleAdsDataByQuery(query, async (streamResponse) =>
{
    try
    {
        if (streamResponse?.Results is null) return;

       //Process each click detail record
        foreach (var clickDetail in streamResponse.Results)
        {
            // Your processing logic here
        }
    }
    catch (Exception e)
    {
        logger.LogError(e, "Error processing click details for date {@date}: {@errorMessage}", date, e.Message);
    }
});

After this method completes:

  • All tasks and async operations have finished.
  • The GC is invoked (automatically).
  • Expected: Unmanaged memory should decrease.
  • Actual: Unmanaged memory remains significantly high and does not decrease.

Client library version and API version:

  • Client library version: Google.Ads.GoogleAds v24.1.0

Attached: Memory snapshots captured after the process completed.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions