How to solve 'Large Local Variables in Viewstate' issue?

Hey, guys! How ou doing today?

My team and I are focused in solve issues indicated on Architecture Dashboard. 

One of them is the 'Large Local Variables in Viewstate' and we are not sure how to fix it. It's not clear if the problem is regarding big structures/variabels or structures/variables in screen scope used inside screen actions (yes, we have many web tradicional applications), things that documentation do not recomend, we know. We are fixind others developers work. 

Sometimes, these structure are not big (2 or 3 attributes) and the AD keep showing error. Did any of you faced something like that? My goal is to bring much information as possible to solve that especifc error. 

Thank you!

mvp_badge
MVP

Hi Lenon,


You can do several things:

  • Make sure Preparation query data is not being used in screen actions without refreshing the query. If you don't do that, the whole query output goes to viewstate, having effect on every AJAX request;
  • Avoid Ifs in your Preparation data (read more here);
  • Persist information in database instead of session or local variables;
    • A good example for that is if you need to upload multiple binaries and you store them in local variables, your screen will be "dead" with so much viewstate. In that scenario, the workaround is to persist the image in the database in a "draft" state;
  • Use your session variables wisely and avoid large variables (read more here).


But of course, you may need to have things stores in session variables and having a structure with 2 attributes is the same of having those two attributes as session variables. The algorithm may tell you to avoid records because in theory it is bad but its real-effect is related to the number of attributes in that structure.


Kind Regards,
João

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.