1
1

I want to discuss a memory issue again. All of the following is performed with a ClientProfile and AutoActivation session and using DO 4.4 in a .NET 3.5 application.

Imagine a FPS game selection screen consisting of three areas. At the top is a row with your current Player information. This is retrieved at the start of the application.

The bottom row consist of two columns. The left one contains the list of available levels for the current game mode. (CTFLevel, DMLevel, ... all extend from Level). The right column contains the detailed level information. Using the MVVM pattern means that, when switching the game mode, only the lower left view is changed. The top row and the right column stay the same. If required their content is updated.

So, a user chooses DM. The view is loaded. A query is performed (on the auto activated session) to get all the DM levels. When a selection is made the current selection object is send to a service (LevelService) which performs some operations and an event is fired telling the lower right column to update. The lower right column shows detailed information which was gathered by the LevelService.

When switching to the CTF game mode the same operation is performed again. The user chooses a Level and presses start. Another service is started which uses LevelService.CurrentSelectedLevel and other information generated from the currently selected Level.

So, the problem is that when I switch to the CTF selection screens all DMLevel objects are still attached to the session. And in my case that's not needed and they use a lot of precious memory. When I start a CTF game all non-selected CTFLevel objects are also attached to the session, and I don't need those either. When I leave the game selection screen to change the application settings non of the Level objects are needed.

One of the things proposed in another support ticket was to close and re-open the session frequently. In a regular WPF application this is not really an option. I need my CurrentUser when starting the game, I need the CurrentSelectedLevel object to know what and how to start. If I close and re-open the session the services holding those objects lose their references.

I know at which point I need to get the information from the database, and I know at which point I no longer need the information from the database. Surely there must be an efficient way to clean those instances up or "detach" them from the session?

What would be the best and most efficient way to get rid of the obsolete entities so the application uses as less memory as needed?

asked Jun 23 '11 at 10:18

jensen's gravatar image

jensen
399913


One Answer:

Hello jensen,

Unfortunately, for now there is no way to clean the DisconnectedState's internal structures that hold references to Entities. We could focus on this issue right after the 4.5 version is released. I hope this path will be acceptable for you.

answered Jun 24 '11 at 04:54

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

I don't think I'll immediately run into any issues, but somewhere in the near future this might become a real problem.

(Jun 24 '11 at 05:20) jensen jensen's gravatar image

OK, I'll include this in our near future plans.

(Jun 24 '11 at 05:30) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA