Cache object vs Session, Application state for datagrid

Discussion in 'ASP .Net Web Services' started by marina.sukhnev@thinknet.com, Mar 2, 2006.

  1. Guest

    Hi Guys!
    I have a question to you,if you know...
    What is the best way to cache dataset for web application.
    Is it Cahce object, session state or application state.
    What a pros and cons? Perfomance,Scalability etc.

    Thanks a lot,

    Marina
    , Mar 2, 2006
    #1
    1. Advertising

  2. Josh Twist Guest

    If you cache something in session state then you'll have one per
    session (i.e. one instance per user). If this isn't what you need use
    the Cache - it's exactly what it's built to do and comes with heaps of
    features like sliding expiration, absolute expiration and is tuned to
    work well in a multi-threaded (IIS/ASP.NET) environment.

    Josh
    http://www.thejoyofcode.com/
    Josh Twist, Mar 2, 2006
    #2
    1. Advertising

  3. Guest

    Hi Josh,
    Thanks for you reply,
    I tried both,Session and Cache,
    When I deal with datagrid that bound to dataset that may have about 900
    -1000 records and trying to edit,delete,update some rows,very soon I'm
    getting out of memory exception. Is 900 rows it too much to handle?
    I'm not setting any features for cache or session,just
    cache("myds")=ds
    session("myds")=ds
    Any suggestions?

    Thank you,
    Marina
    , Mar 2, 2006
    #3
  4. Josh Twist Guest

    I doubt it's the 900 rows themselves causing you problems (it's not
    that many) and if the dataset wasn't cached you'd have one instance
    loaded into memory for each request (so potentially using even more
    memory on a busy server).

    Maybe there is something about the modification of datasets that makes
    it chew up memory?? Also, you need to bear in mind that IIS/ASP.NET is
    a multithreaded environment so different threads could be accessing the
    dataset at the sametime. MSDN has this to say about the thread safety
    of datasets: "This type is safe for multithreaded read operations. You
    must synchronize any write operations."

    Are you synchronising your write operations? This is a pitfall to
    beware of, though I'm not sure this is what would be causing your
    memory to be chewed up.

    I'm afraid DataSets are not something I use in ASP.NET [see links
    below] so It's really not an area I'm very strong in. If I was in your
    position now I might use the CLR Profiler to see what's happening to
    all your memory:
    http://msdn.microsoft.com/library/en-us/dnpag/html/scalenethowto13.asp?frame=true

    links
    http://aspnet.4guysfromrolla.com/articles/050405-1.aspx
    http://aspnet.4guysfromrolla.com/articles/051805-1.aspx

    Good luck

    Josh
    http://www.thejoyofcode.com/
    Josh Twist, Mar 3, 2006
    #4
  5. Guest

    Josh Twist wrote:
    > I doubt it's the 900 rows themselves causing you problems (it's not
    > that many) and if the dataset wasn't cached you'd have one instance
    > loaded into memory for each request (so potentially using even more
    > memory on a busy server).
    >
    > Maybe there is something about the modification of datasets that makes
    > it chew up memory?? Also, you need to bear in mind that IIS/ASP.NET is
    > a multithreaded environment so different threads could be accessing the
    > dataset at the sametime. MSDN has this to say about the thread safety
    > of datasets: "This type is safe for multithreaded read operations. You
    > must synchronize any write operations."
    >
    > Are you synchronising your write operations? This is a pitfall to
    > beware of, though I'm not sure this is what would be causing your
    > memory to be chewed up.
    >
    > I'm afraid DataSets are not something I use in ASP.NET [see links
    > below] so It's really not an area I'm very strong in. If I was in your
    > position now I might use the CLR Profiler to see what's happening to
    > all your memory:
    > http://msdn.microsoft.com/library/en-us/dnpag/html/scalenethowto13.asp?frame=true
    >
    > links
    > http://aspnet.4guysfromrolla.com/articles/050405-1.aspx
    > http://aspnet.4guysfromrolla.com/articles/051805-1.aspx
    >
    > Good luck
    >
    > Josh
    > http://www.thejoyofcode.com/



    Thanks Josh for your help,
    I'll try CLR Profiler...
    , Mar 7, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shamanthakamani
    Replies:
    1
    Views:
    3,473
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    593
    Not Liking Dot Net Today
    Apr 21, 2004
  3. Replies:
    1
    Views:
    273
    Peter Bromberg [C# MVP]
    Jun 4, 2008
  4. Cache vs Session, Application state for datagrid

    , Mar 2, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    11
    Views:
    315
    Elton Wang
    Mar 3, 2006
  5. Marisha
    Replies:
    1
    Views:
    129
    Marisha
    Mar 6, 2006
Loading...

Share This Page