This is an array question but it is based in my web page so i shall give
scenario:
when the client navigates to the page, the page takes some figures and does
loads of calulations in page_load which result in an array with 4.8 million
elements. i then extract a mere handful which is all the client needs and
then return these results to the client. I would therefore like to delete
the array from memory at the end of the page_load event. Can someone
please tell me how to do this. thanks. 5 12367
All you have to do is make sure that the array is not being referenced in
the Application or Session objects (that you're not purposely keeping it
alive across page requests) and .NET will decide upon the best time to
collect it. In .NET you don't explicitly control memory; check out the top
hits for .NET memory management at Google: http://www.google.com/search?hl=en&i...ory+management
for in-depth explainations.
Richard
--
C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@140.99.99.1 30... This is an array question but it is based in my web page so i shall give scenario:
when the client navigates to the page, the page takes some figures and
does loads of calulations in page_load which result in an array with 4.8
million elements. i then extract a mere handful which is all the client needs and then return these results to the client. I would therefore like to delete the array from memory at the end of the page_load event. Can someone please tell me how to do this. thanks.
But you can control the GC...
GC.Collect(GC.MaxGeneration); // forces a full collect
GC.Collect(GC.GetGeneration(myArray)); // forces a collect up to the generation
your array is in
This isn't recommended, but if you are doing this calculation simultaneously for
many users you may
have a worker process roll-over (denial of service for some short period of
time) before the weight
on the GC forces it to kick in and collect. You need to weight roll-overs using
the process counter
and if they are high then you should manually control the GC since you know the
best time to collect
your objects and the GC only makes guesses.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:e0*************@TK2MSFTNGP12.phx.gbl... All you have to do is make sure that the array is not being referenced in the Application or Session objects (that you're not purposely keeping it alive across page requests) and .NET will decide upon the best time to collect it. In .NET you don't explicitly control memory; check out the top hits for .NET memory management at Google: http://www.google.com/search?hl=en&i...ory+management for in-depth explainations.
Richard
-- C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard "tony collier" <me*****@hotmail.com> wrote in message news:Xn*******************************@140.99.99.1 30... This is an array question but it is based in my web page so i shall give scenario:
when the client navigates to the page, the page takes some figures and does loads of calulations in page_load which result in an array with 4.8 million elements. i then extract a mere handful which is all the client needs and then return these results to the client. I would therefore like to delete the array from memory at the end of the page_load event. Can someone please tell me how to do this. thanks.
> and if they are high then you should manually control the GC since you
know the best time to collect your objects and the GC only makes guesses.
Justin, have you implemented and tested this in a real world app? I'm not
trying to be rhetorical - I'm really asking, since I've never had the
experience of using GC outside of simple test/diagnostic apps (and everytime
I have tried to use it other places, people smarter than I have taken me to
task for it :). It still seems risky to me to call the GC, perhaps even
every time this page fires, in light of the potential expense of GC in
ASP.NET especially - but I will defer to our resident gurus.
One alternative for this kind of thing is running code in an AppDomain, then
unloading it, which I gave an example of doing here: http://blogs.geekdojo.net/richard/ar...12/10/428.aspx
This certainly has some expense to it, but seems to work well enough at
deterministically removing memory.
Richard
--
C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:uZ*************@TK2MSFTNGP11.phx.gbl... But you can control the GC...
GC.Collect(GC.MaxGeneration); // forces a full collect GC.Collect(GC.GetGeneration(myArray)); // forces a collect up to the
generation your array is in
This isn't recommended, but if you are doing this calculation
simultaneously for many users you may have a worker process roll-over (denial of service for some short period
of time) before the weight on the GC forces it to kick in and collect. You need to weight roll-overs
using the process counter and if they are high then you should manually control the GC since you
know the best time to collect your objects and the GC only makes guesses.
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message news:e0*************@TK2MSFTNGP12.phx.gbl... All you have to do is make sure that the array is not being referenced
in the Application or Session objects (that you're not purposely keeping it alive across page requests) and .NET will decide upon the best time to collect it. In .NET you don't explicitly control memory; check out the
top hits for .NET memory management at Google: http://www.google.com/search?hl=en&i...ory+management for in-depth explainations.
Richard
-- C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard "tony collier" <me*****@hotmail.com> wrote in message news:Xn*******************************@140.99.99.1 30... This is an array question but it is based in my web page so i shall
give scenario:
when the client navigates to the page, the page takes some figures and does loads of calulations in page_load which result in an array with 4.8 million elements. i then extract a mere handful which is all the client needs
and then return these results to the client. I would therefore like to
delete the array from memory at the end of the page_load event. Can someone please tell me how to do this. thanks.
For about six months we used it in the .NET Terrarium application. Until the
GC caught up with our expectations and we didn't need it anymore. During that
time there was a deterministic location we could call from (between game ticks)
that caused a low impact on our application at hand and so it worked perfectly.
In this guy's case, he has a couple of options:
1. Don't GC at all, and hope that the worker process doesn't role over
constantly
2. Don't GC at all, and hope that the memory used on the array gets re-used for
the next array
3. GC if he finds that either 1 or 2 isn't coming true.
So what I am saying is pick the lesser of several evils depending on his own
goals and
inspection of what is happening on his servers. Generally speaking, #2 should
come into
play for him, since the memory should get re-used after it goes out of scope.
The largest problem
I see is that he is allocating a huge array, and allocating huge arrays
generally means finding
contiguous locations in memory for said arrays. Because of these types of
allocations in addition
to more normal allocations he might find situations where the managed heap grows
uncontrollably (e.g.
very fast in a short amount of time, causing the work process to role)
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl... and if they are high then you should manually control the GC since you know the best time to collect your objects and the GC only makes guesses.
Justin, have you implemented and tested this in a real world app? I'm not trying to be rhetorical - I'm really asking, since I've never had the experience of using GC outside of simple test/diagnostic apps (and everytime I have tried to use it other places, people smarter than I have taken me to task for it :). It still seems risky to me to call the GC, perhaps even every time this page fires, in light of the potential expense of GC in ASP.NET especially - but I will defer to our resident gurus.
One alternative for this kind of thing is running code in an AppDomain, then unloading it, which I gave an example of doing here: http://blogs.geekdojo.net/richard/ar...12/10/428.aspx
This certainly has some expense to it, but seems to work well enough at deterministically removing memory.
Richard -- C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard "Justin Rogers" <Ju****@games4dotnet.com> wrote in message news:uZ*************@TK2MSFTNGP11.phx.gbl... But you can control the GC...
GC.Collect(GC.MaxGeneration); // forces a full collect GC.Collect(GC.GetGeneration(myArray)); // forces a collect up to the generation your array is in
This isn't recommended, but if you are doing this calculation simultaneously for many users you may have a worker process roll-over (denial of service for some short period of time) before the weight on the GC forces it to kick in and collect. You need to weight roll-overs using the process counter and if they are high then you should manually control the GC since you know the best time to collect your objects and the GC only makes guesses.
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message news:e0*************@TK2MSFTNGP12.phx.gbl... All you have to do is make sure that the array is not being referenced in the Application or Session objects (that you're not purposely keeping it alive across page requests) and .NET will decide upon the best time to collect it. In .NET you don't explicitly control memory; check out the top hits for .NET memory management at Google: http://www.google.com/search?hl=en&i...ory+management for in-depth explainations.
Richard
-- C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard "tony collier" <me*****@hotmail.com> wrote in message news:Xn*******************************@140.99.99.1 30... > This is an array question but it is based in my web page so i shall give > scenario: > > when the client navigates to the page, the page takes some figures and does > loads of calulations in page_load which result in an array with 4.8 million > elements. i then extract a mere handful which is all the client needs and > then return these results to the client. I would therefore like to delete > the array from memory at the end of the page_load event. Can someone > please tell me how to do this. thanks.
Okay, so I would suggest an option 4 - Do all 'excessive' memory work in a
temporary AppDomain, and reclaim the memory when the AppDomain is unloaded.
This is partly speculation on my part, but it seems this would mean
targeted, deterministic removal of only the memory allocated for the 'large
memory process' and leave the GC to do it's work normally on the range of
objects created in a normal ASP.NET page request.
Worth a try, IMHO,
Richard
--
C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... For about six months we used it in the .NET Terrarium application. Until
the GC caught up with our expectations and we didn't need it anymore. During
that time there was a deterministic location we could call from (between game
ticks) that caused a low impact on our application at hand and so it worked
perfectly. In this guy's case, he has a couple of options: 1. Don't GC at all, and hope that the worker process doesn't role over constantly 2. Don't GC at all, and hope that the memory used on the array gets
re-used for the next array 3. GC if he finds that either 1 or 2 isn't coming true.
So what I am saying is pick the lesser of several evils depending on his
own goals and inspection of what is happening on his servers. Generally speaking, #2
should come into play for him, since the memory should get re-used after it goes out of
scope. The largest problem I see is that he is allocating a huge array, and allocating huge arrays generally means finding contiguous locations in memory for said arrays. Because of these types of allocations in addition to more normal allocations he might find situations where the managed heap
grows uncontrollably (e.g. very fast in a short amount of time, causing the work process to role)
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message news:ex**************@TK2MSFTNGP09.phx.gbl... and if they are high then you should manually control the GC since you know the best time to collect your objects and the GC only makes guesses.
Justin, have you implemented and tested this in a real world app? I'm
not trying to be rhetorical - I'm really asking, since I've never had the experience of using GC outside of simple test/diagnostic apps (and
everytime I have tried to use it other places, people smarter than I have taken me
to task for it :). It still seems risky to me to call the GC, perhaps
even every time this page fires, in light of the potential expense of GC in ASP.NET especially - but I will defer to our resident gurus.
One alternative for this kind of thing is running code in an AppDomain,
then unloading it, which I gave an example of doing here: http://blogs.geekdojo.net/richard/ar...12/10/428.aspx
This certainly has some expense to it, but seems to work well enough at deterministically removing memory.
Richard -- C#, .NET and Complex Adaptive Systems: http://blogs.geekdojo.net/Richard "Justin Rogers" <Ju****@games4dotnet.com> wrote in message news:uZ*************@TK2MSFTNGP11.phx.gbl... But you can control the GC...
GC.Collect(GC.MaxGeneration); // forces a full collect GC.Collect(GC.GetGeneration(myArray)); // forces a collect up to the generation your array is in
This isn't recommended, but if you are doing this calculation simultaneously for many users you may have a worker process roll-over (denial of service for some short
period of time) before the weight on the GC forces it to kick in and collect. You need to weight
roll-overs using the process counter and if they are high then you should manually control the GC since you know the best time to collect your objects and the GC only makes guesses.
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message news:e0*************@TK2MSFTNGP12.phx.gbl... > All you have to do is make sure that the array is not being
referenced in > the Application or Session objects (that you're not purposely
keeping it > alive across page requests) and .NET will decide upon the best time
to > collect it. In .NET you don't explicitly control memory; check out
the top > hits for .NET memory management at Google: > http://www.google.com/search?hl=en&i...ory+management > for in-depth explainations. > > Richard > > -- > C#, .NET and Complex Adaptive Systems: > http://blogs.geekdojo.net/Richard > "tony collier" <me*****@hotmail.com> wrote in message > news:Xn*******************************@140.99.99.1 30... > > This is an array question but it is based in my web page so i
shall give > > scenario: > > > > when the client navigates to the page, the page takes some figures
and > does > > loads of calulations in page_load which result in an array with
4.8 > million > > elements. i then extract a mere handful which is all the client
needs and > > then return these results to the client. I would therefore like
to delete > > the array from memory at the end of the page_load event. Can
someone > > please tell me how to do this. thanks. > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pelle |
last post by:
Hello all,
I have to admit, that the idea that occurred to me recently is weird.
It was somehow inspired by the huge response on the "delete operator"
thread, but goes into a somewhat different...
|
by: peter |
last post by:
Hello,
for a C++ delete:
class Test{};
Test * A = new Test;
delete A;
We don't use delete A;
How can C++ compiler can tell there are 50 destructor to deallocate?
|
by: Nimmi Srivastav |
last post by:
There's a rather nondescript book called "Using Borland C++" by Lee
and Mark Atkinson (Que Corporation) which presents an excellent
discussion of overloaded new and delete operators. In fact there...
|
by: Jonan |
last post by:
Hello,
For several reasons I want to replace the built-in memory management with
some custom built. The mem management itlsef is not subject to my question -
it's ok to the point that I have...
|
by: fermisoft |
last post by:
I have a strange problem in my project.
I have a class like this......
class CMsg
{
public:
void *m_body;
~CMsg()
|
by: AB |
last post by:
Hi all,
A thought crossed my mind....
if I allocate memory for an array at runtime using....
int* arr = new int ;
what happens when I then de-allocate memory using
|
by: mkaushik |
last post by:
Hi everyone,
Im just starting out with C++, and am curious to know how "delete
<pointer>", knows about the number of memory locations to free.
I read somewhere that delete frees up space...
|
by: Money |
last post by:
If I allocate memory like this
int *ptr = new int;
Can I apply delete ptr; instead of delete ptr; since I am only
allocating memory for 1 integer.
|
by: yufufi |
last post by:
Hello,
How does delete know how much memory to deallocate from the given
pointer? AFAIK this informations is put there by new. new puts the
size of the allocated memory before the just before...
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello everyone,
I remembered delete is implemented through operator overloading, but I am
not quite clear.
Could anyone recommend some links about how delete is implemented so that
I can...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |