473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Something very strange

Hi guys,

I have an object eg GlobalObject with some Public Static properties that I
set them throughout the session from each page.
I need these values to be shared among all the pages.

The funny part is that even I stop the application and close the IE etc
when i rerun the program still some of the
values not changed. Looks like that object is not removed by GC.

How can i remove this object to make sure all the values are gone when the
session is finished.

How can i make sure it is done?

TIa
Nov 17 '05 #1
5 1242
Definition of the static keyword can be found here:

http://msdn.microsoft.com/library/de...rfstaticpg.asp

It sounds as though you are writing a web based application, this means that when you stop using your application and close your browser this does not stop the application on the web server that processes the requests. This will only stop when the worker process on ther web server recycles or the web server is stopped.

Static variables live for the lifetime of the application so therefore what you are seeing is correct the variables will live unitl the worker process on the web server is terminated.

If you want to clear out a variable when a session finishes check out session_end '
protected void Session_End(Object sender, EventArgs e)' event in the glogal.asax.cs file of your project you can assign the variable to null in there.


HTH

Ollie Riches


"Annie" <my**************@gmail.com> wrote in message news:43********@dnews.tpgi.com.au...
Hi guys,

I have an object eg GlobalObject with some Public Static properties that I
set them throughout the session from each page.
I need these values to be shared among all the pages.

The funny part is that even I stop the application and close the IE etc
when i rerun the program still some of the
values not changed. Looks like that object is not removed by GC.

How can i remove this object to make sure all the values are gone when the
session is finished.

How can i make sure it is done?

TIa

Nov 17 '05 #2
Annie wrote:
Hi guys,

I have an object eg GlobalObject with some Public Static properties
that I set them throughout the session from each page.
I need these values to be shared among all the pages.

The funny part is that even I stop the application and close the IE
etc when i rerun the program still some of the
values not changed. Looks like that object is not removed by GC.

How can i remove this object to make sure all the values are gone
when the session is finished.

How can i make sure it is done?

TIa


In addition to what Ollie Riches said:

Watch out with static variables in a web environment, as they are
visible Application-wide. And the single web-application serves
all users, so that value is visible to *all* users!

Note: there is also a ...dotnet.framework.aspnet group, for ASP.Net
related questions.

Hans Kesting
Nov 17 '05 #3
Thanks guys for the reply.

I already did as Ollie was suggesting but I really didn't know why it was
happening.

Ollie,

How long the worker process remain active? even if I close the browser and
stop the application?

I think Hans suggestion is very appropriate I have to be careful for those
settings as it is a multiuser environemnt!

thanks

"Annie" <my**************@gmail.com> wrote in message
news:43********@dnews.tpgi.com.au...
Hi guys,

I have an object eg GlobalObject with some Public Static properties that I
set them throughout the session from each page.
I need these values to be shared among all the pages.

The funny part is that even I stop the application and close the IE etc
when i rerun the program still some of the
values not changed. Looks like that object is not removed by GC.

How can i remove this object to make sure all the values are gone when the
session is finished.

How can i make sure it is done?

TIa

Nov 17 '05 #4
what version of IIS (web server) is the application running on? I guess you
are using an XP machine - it will have IIS 5.1

Ollie Riches

"Annie" <my**************@gmail.com> wrote in message
news:43******@dnews.tpgi.com.au...
Thanks guys for the reply.

I already did as Ollie was suggesting but I really didn't know why it was
happening.

Ollie,

How long the worker process remain active? even if I close the browser and
stop the application?

I think Hans suggestion is very appropriate I have to be careful for those
settings as it is a multiuser environemnt!

thanks

"Annie" <my**************@gmail.com> wrote in message
news:43********@dnews.tpgi.com.au...
Hi guys,

I have an object eg GlobalObject with some Public Static properties that
I set them throughout the session from each page.
I need these values to be shared among all the pages.

The funny part is that even I stop the application and close the IE etc
when i rerun the program still some of the
values not changed. Looks like that object is not removed by GC.

How can i remove this object to make sure all the values are gone when
the session is finished.

How can i make sure it is done?

TIa


Nov 17 '05 #5
ya that is correct.
I run under windows XP Professional version
"Annie" <my**************@gmail.com> wrote in message
news:43********@dnews.tpgi.com.au...
Hi guys,

I have an object eg GlobalObject with some Public Static properties that I
set them throughout the session from each page.
I need these values to be shared among all the pages.

The funny part is that even I stop the application and close the IE etc
when i rerun the program still some of the
values not changed. Looks like that object is not removed by GC.

How can i remove this object to make sure all the values are gone when the
session is finished.

How can i make sure it is done?

TIa

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Karl Roes | last post by:
Hi All, I have a form with a standard combo box and 5 tabs in A2003. On Form Open, I set Me.Detail.Visible = False and in the after update event of the combo set Me.Detail.Visible = True,( to...
0
by: harrylmh | last post by:
Hi, I found something strange about the mouse's X,Y coordinates. Here's a program I made for testing. Start by moving your mouse over the Label on the left, then...move your mouse slowly from left...
20
by: SpreadTooThin | last post by:
I have a list and I need to do a custom sort on it... for example: a = #Although not necessarily in order def cmp(i,j): #to be defined in this thread. a.sort(cmp) print a
3
by: Beemer Biker | last post by:
I started seeing huge amounts of error messages such as "Validation (XHTML 1.0 Transitional):" Element schema is not supported". There was nothing wrong with that for 3 weeks and suddenly there...
6
by: =?Utf-8?B?TWljaGVsIFBvc3NldGggW01DUF0=?= | last post by:
Hello i just encountered a funny situation Dim i As Integer = 0 MsgBox(i = Nothing) and
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.