c# - Improving .Net memory speed and efficiency -
i have service, query once in long while, , "streamline", or improve efficiency, of memory allocation.
most of time sits , waits, , once in awhile gets request requires allocating lot of memory, , processing on it. don't know types or structure in advance - depends on request, , varies wildly.
now, big processing request precluded chatter (other requests), might take few seconds.
what want is, when chatter (smaller requests) start, .net framework: go windows, , couple of gb's of memory it'll available faster when ask, , when i'm done, .net: i'm not using, can give back, because i'm not going need while.
i'm starting profiling speak... suspect part of issues improve.
i'll try clarify situation.
i have service sits on server , 95% of time nothing. once in long while gets request memory intensive processing.
i know little bit of time in advance it's going happen.
all want do, hint gc "were going need lot of memory soon" , later "were not going need special while"
ok. i've done profiling, , decided don't care this. allocation take time (several several dozens milliseconds), it's insignificant versus rest of processing...
regarding releasing part, happens eventually, , doesn't interfere rest of server...
the gc of time smart enough you. however, architectural problem , can dealt modifying flow of activities in service.
e.g. can allocate objects required processing big request in advance before request comes. however, deallocating, either explicitly implement idisposible interface them , destroy them once used or leave gc.
further, have understand how memory allocation works. in order memory allocated .net objects, must knowing type of object in advance. allocating plain block of memory in no way helpful you. of time object creation or cloning code more resource consuming compared mallocs framework uses allocate memory object.
considering details, if routine, become more complex , might add few more bugs code. better leave .net framework. @ allocating , deallocating memory.
Comments
Post a Comment