Page 1 of 1

WPF Map Control memory cache limit?

Posted: Thu Jul 03, 2014 10:19 am
by kecskemetib
Dear Forum,

We are using the WPF MAP control (Ptv.XServer.Controls.Map.WpfMap) in one of our .NET 4.5 applications. We have noticed, that the control is caching the map images in the memory as the user is using the map. We would like to limit the WPF MAP control's memory usage to a fixed amount, like 100 MB, but we didn't find any solution for this problem.
It is very important to our client because their users are using shared memory and without this limitation a user can consume a huge amount of memory from other users.

Is there any documentation or sample code on how we can configure the memory limit with the map contol?

Thank you,
Balázs

Re: WPF Map Control memory cache limit?

Posted: Mon Jul 07, 2014 12:05 pm
by Oliver Heilig
Hi Balázs,

The tile cache for the WPF control has size of 500 tiles. If you assume 20KB for an average tile image you'll never get more than 10MB. You cannot directly change the cache size. But you can inherit you own class and set it as global cache, see code below.

Code: Select all

    public class MyCache : TileCache
    {
        public MyCache(int size)
        {
            CacheSize = size;
        }
    };

        public MainWindow()
        {
            Ptv.XServer.Controls.Map.Tools.TileCache.GlobalCache = new MyCache(100);

            // Initialization.
            InitializeComponent();