Search code examples
memory-managementpinvokeazure-worker-roles

Worker role starts with reasonable memory usage but then memory usage increases constantly


I have a worker role which runs multiple threads(I used ThreadedWorkerRole). My worker role downloads some data and then images related to that data. Everything works fine locally but when I deploy the app on azure, It starts by showing a reasonable memory usage(48 MB) but then it shoots to the 800 MB within 1 or 2 hours. My application did care disposing the objects with lots of "using" statements and closing the streams properly. But I still wonder what cause the memory to jump at such a high value. One More thing, I have used RETSLib(PInvoke library to hit RETS server) which downloads data and images. Can it be the issue of Unmanaged code?


Solution

  • It can definitely be the issue of unmanaged code leaking memory. Is RETSLib a .net wrapper on librets? Some references to php implementations of librets leaking memory.

    You mention "downloads some data and then images related to that data". Are you using Entity Framework to get this initial data or store it into SQL? If so I am assuming that you dispose of the ObjectContext. There have been instances where EF 4.0 seems to have some memory issues.
    A link (old) that talks about this.

    Could have added this as a comment but stackoverflow would not allow me to do so on account of my low rep points