Note that there are some explanatory texts on larger screens.

plurals
  1. POScheduled Agent memory leak
    primarykey
    data
    text
    <p>Greeting everybody, i'm having a problem of memory leak in ScheduledAgent of my WP8 app. What i'm trying to do, is update multipe tiles of the app in a loop, and it seems ok (in regard of memory usege), but for some reason memory is not released after a tile is updated.</p> <p>My code looks like this (memory usage mesured by Microsoft.Phone.Info.DeviceStatus.ApplicationCurrentMemoryUsage):</p> <pre><code>protected override void OnInvoke(ScheduledTask task) { try { Deployment.Current.Dispatcher.BeginInvoke(() =&gt; { // 5MB used foreach (int id in myIdsList) UpdateTile(id); }); } catch (Exception e) { if (Debugger.IsAttached) Debugger.Break(); } NotifyComplete(); } </code></pre> <p>The update method looks like this:</p> <pre><code>public void UpdateTile(int id) { MyClass myClassInstance = GetInstanceById(id); //~6MB used by now Canvas drawingSurface = new Canvas(); //Add some Image objects to canvas (source to each image is a filePath // contained in myClassInstance) //~7MB WriteableBitmap bigTileImage = new WriteableBitmap(691, 336); bigTileImage.Render(drawingSurface, null); bigTileImage.Invalidate(); //~9MB var bigTilePath = string.Format(/*path here*/); using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (storage.FileExists(bigTilePath)) storage.DeleteFile(bigTilePath); using (var isoFileStream = new IsolatedStorageFileStream( bigTilePath, FileMode.Create, storage)) { bigTileImage.SaveJpeg(isoFileStream, bigTileImage.PixelWidth, bigTileImage.PixelHeight, 0, 100); } } ShellTile tileToUpdate = ShellTile.ActiveTiles.FirstOrDefault( x =&gt; x.NavigationUri.ToString().Contains("TileID="+id)); FlipTileData flipTileData = new FlipTileData() { //Set fields WideBackgroundImage = new Uri(("isostore:/"+bigTilePath, UriKind.Absolute), }; tileToUpdate.Update(flipTileData); //~10MB used //Shouldn't memory be released by now?? // calling GC.Collect() has no effect } </code></pre> <p>So, it's a PeriodicTask, and i have memory cap of 11MB and as far as memory is not releasing after an iteration i get OutOfMemoryException. </p> <p>Maybe I do not understand the basics, but i think that most of taken memory should be released after saving file to IS (or whenever GC decides to collect, but, as I said even explicitly calling <code>GC.Collect()</code> has no effect)?</p> <p>Am I doing something wrong? Is there a way to release the memory?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload