Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ramd21 · Apr 08, 2019 at 08:47 PM · bugwwwmemory-leak

UnityWebRequest leaking memory.

Would someone try this program? Please tell me If it leaks memory or not.

 using System.Collections;
 using UnityEngine;
 using UnityEngine.Networking;
 
 public class MemoryLeak : MonoBehaviour
 {
     public string _Url = "https://www.google.com/";
 
     public int _LoopCnt;
 
     void Start()
     {
         Loop();
     }
 
     void Loop()
     {
         StartCoroutine(Send());
     }
 
     IEnumerator Send()
     {
         using (UnityWebRequest request = UnityWebRequest.Get(_Url))
         {
             yield return request.SendWebRequest();
         }
 
         _LoopCnt++;
         Loop();
     }
 }


On Unity 2018.2.13f1 (64-bit), this program will crash on windows. Looks like leaking memory as I observed windows task manager.

On Unity 2018.1.9f2 (64-bit) it will not leak memory.
I found that newer than Unity 2018.1.9f2 (64-bit) it will leak memory.

I reported this as bug to Unity team but they say they can not reproduce it.

Is this happening only on my environment?
I am using Japanese Windows 10 home.
CPU AMD Ryzen 5 1600X.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by AnalogyBoy · Jul 27, 2020 at 10:05 AM

@ramd21 did you find a solution?

I have a big problem which aligns well and appears to correspond exactly to the following Mono leak. https://github.com/mono/mono/issues/8689

I use await/async with DynamoDB queries and the result is 1000s of system.byte[] arrays hanging around uncollected by the GC. String allocations seem to be growing in a correlated way too. Over a day or two i'm losing 100mb or more.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bunny83 · Jul 27, 2020 at 10:17 AM

Well it's not clear if the issue is the web request. You should never constantly make a coroutine calling itself. A coroutine requires memory and need to be garbage collected as well. Is that your actual testing code? You don't do anything with the returned data?


Instead of making your coroutine calling itself, you should simply use a loop:

 IEnumerator Send()
 {
     while (true)
     {
         using (UnityWebRequest request = UnityWebRequest.Get(_Url))
         {
             yield return request.SendWebRequest();
         }
         _LoopCnt++;
     }
 }

This has the exact same effect but without any nested coroutines.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

119 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Assetbundle memory leaks 0 Answers

Unload asset loaded with WWW class 1 Answer

WWW http request loads way to long on IOS 0 Answers

Memory Leak by www? 1 Answer

WWW responseHeaders not giving me cookie in web-player, but does in editor 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges