By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,474 Members | 3,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,474 IT Pros & Developers. It's quick & easy.

Caching to an Application Variable, and Performance Issues

P: n/a
Hi, I couldn't find what I was looking for by searching the newsgroup, but perhaps these have already been discussed somewhere. This is a bit long with a lot of interrelated questions.

What I've got is a decodeImage.aspx page that gets called to decode base64 encoded images and return them as displayable images to a Web page. The ASPX page is passed two parameters, "file" and "img". The "file" parameter specifies and XML file on the Web server that contains data including base64 encoded images. The "img" parameter specifies an index to identify which image should be encoded and returned. There could be any number of images to be decoded in the XML file, and their size is also uncertain.

My concern is that if a particular page calls this decodeImage.aspx page numerous times that I am wasting valuable time and efforts by having the XML file loaded each and every time. If I am wrong and this file is not reloaded each time, please let me know, but it's my understanding it will be loaded each time.

So what I was thinking was to cache as an Application variable in the XmlNodeList that was populated with a call to SelectNodes, and name the variable based on the "file" parameter. Then if I find that the variable already exists, use the cached object instead of reloading. Since these images are used site wide, I didn't think a Session variable was appropriate. There can be any number of XML files used, so there could be any number of Application variables that need to be set.

That seems fairly straightforward, but I have a few concerns with that:
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable over having it reloaded?
2. What is the max size for an Application variable?
3. What is the max size for all Application variables together?
4. What actually happens when that size limit has been reached?
5. Once each image have been decoded, are they cached on the server for the Web page to use, or will the Web page always and forever call in to redecode the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
6. How do I find out when the XML file has been updated so that I know to update the Application variable?

I think that about covers it. If I think of anything else related to this scenario, I'll do a followup post.

Thanks ahead of time for your help!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

Nov 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Greg,

1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

2. What is the max size for an Application variable?

AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).

3. What is the max size for all Application variables together?

Same as above.

4. What actually happens when that size limit has been reached?

I would imagine an "out of memory" exception, but that's just a guess.

5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?

If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself. If
these XML documents are needed for the lifetime of the Application, you can
do that as well. No harm done. When the Application ends, the Collection is
automatically released.

6. How do I find out when the XML file has been updated so that I know to
update the Application variable?

You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#l**************@tk2msftngp13.phx.gbl...
Hi, I couldn't find what I was looking for by searching the newsgroup, but
perhaps these have already been discussed somewhere. This is a bit long with
a lot of interrelated questions.

What I've got is a decodeImage.aspx page that gets called to decode base64
encoded images and return them as displayable images to a Web page. The ASPX
page is passed two parameters, "file" and "img". The "file" parameter
specifies and XML file on the Web server that contains data including base64
encoded images. The "img" parameter specifies an index to identify which
image should be encoded and returned. There could be any number of images to
be decoded in the XML file, and their size is also uncertain.

My concern is that if a particular page calls this decodeImage.aspx page
numerous times that I am wasting valuable time and efforts by having the XML
file loaded each and every time. If I am wrong and this file is not reloaded
each time, please let me know, but it's my understanding it will be loaded
each time.

So what I was thinking was to cache as an Application variable in the
XmlNodeList that was populated with a call to SelectNodes, and name the
variable based on the "file" parameter. Then if I find that the variable
already exists, use the cached object instead of reloading. Since these
images are used site wide, I didn't think a Session variable was
appropriate. There can be any number of XML files used, so there could be
any number of Application variables that need to be set.

That seems fairly straightforward, but I have a few concerns with that:
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?
2. What is the max size for an Application variable?
3. What is the max size for all Application variables together?
4. What actually happens when that size limit has been reached?
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?

I think that about covers it. If I think of anything else related to this
scenario, I'll do a followup post.

Thanks ahead of time for your help!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com


Nov 18 '05 #2

P: n/a
see inline >> comments:

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
| Hi Greg,
|
| 1. Can I store the XmlNodeList object and restore it for use the next
time?
| a. If not, is there any advantage to storing the XML in the variable
| over having it reloaded?
|
| The Application and Application Cache are Collections, pure and simple.
| Well, the Cache is a specialized type of Collection, but it is, underneath
| the specialization (extra methods, fields, etc) a Collection. They are, in
| essence, Name and Object Collections.
there is one difference between the application cache and the application collections.
if memory usage gets high, entries in the cache will automatically be
removed.

|
| As everything in .Net is an object, you can store anything in these
| Collections, and use them just as you would any object in any Collection.
|
| The advantage of storing your XML in the Collection is the saving of IO
| processing and the processing involved in reading the XML from the file
into
| an object. So, yes, there is an advantage in terms of performance.
|
| 2. What is the max size for an Application variable?
|
| AFAIK, there is no maximum size, other than memory capacity. At least,
I've
| never run into one. And I have put a LOT of data in the Cache before
(dozens
| of MB).
|
| 3. What is the max size for all Application variables together?
|
| Same as above.
see below
|
| 4. What actually happens when that size limit has been reached?
|
| I would imagine an "out of memory" exception, but that's just a guess.
if you look in machine.config/web.config, there is a setting for the max amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).

|
| 5. Once each image have been decoded, are they cached on the server for
the
| Web page to use, or will the Web page always and forever call in to
redecode
| the image each time?
| a. If so, I'd like to know my alternatives.
| b. If not, how do I know when to release that variable?
|
| If you put them into a Collection, such as Application or Cache, they are
| cached. How do you know when to release that variable? Well, it's not a
| variable, it's a member object of a Collection. Using the Cache, you can
| tell the Cache when to remove the object, or you can remove it yourself.
If
| these XML documents are needed for the lifetime of the Application, you
can
| do that as well. No harm done. When the Application ends, the Collection
is
| automatically released.
|
| 6. How do I find out when the XML file has been updated so that I know to
| update the Application variable?
|
| You could use a FileSystemWatcher to watch for changes in the folder
| containing the files, and have it respond to them. You could even cache
the
| FileSystemWatcher, so that it resides in the Application and works for the
| lifetime of the Application.
|
if you use the application cache object you can place a cache dependency

on the file, and the cache will release the object automatically if the file
is changed.
| --
| HTH,
| Kevin Spencer
| .Net Developer
| Microsoft MVP
| I get paid good money to
| solve puzzles for a living
|
| "Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
| news:#l**************@tk2msftngp13.phx.gbl...
| Hi, I couldn't find what I was looking for by searching the newsgroup, but
| perhaps these have already been discussed somewhere. This is a bit long
with
| a lot of interrelated questions.
|
| What I've got is a decodeImage.aspx page that gets called to decode base64
| encoded images and return them as displayable images to a Web page. The
ASPX
| page is passed two parameters, "file" and "img". The "file" parameter
| specifies and XML file on the Web server that contains data including
base64
| encoded images. The "img" parameter specifies an index to identify which
| image should be encoded and returned. There could be any number of images
to
| be decoded in the XML file, and their size is also uncertain.
|
| My concern is that if a particular page calls this decodeImage.aspx page
| numerous times that I am wasting valuable time and efforts by having the
XML
| file loaded each and every time. If I am wrong and this file is not
reloaded
| each time, please let me know, but it's my understanding it will be loaded
| each time.
|
| So what I was thinking was to cache as an Application variable in the
| XmlNodeList that was populated with a call to SelectNodes, and name the
| variable based on the "file" parameter. Then if I find that the variable
| already exists, use the cached object instead of reloading. Since these
| images are used site wide, I didn't think a Session variable was
| appropriate. There can be any number of XML files used, so there could be
| any number of Application variables that need to be set.
|
| That seems fairly straightforward, but I have a few concerns with that:
| 1. Can I store the XmlNodeList object and restore it for use the next
time?
| a. If not, is there any advantage to storing the XML in the variable
| over having it reloaded?
| 2. What is the max size for an Application variable?
| 3. What is the max size for all Application variables together?
| 4. What actually happens when that size limit has been reached?
| 5. Once each image have been decoded, are they cached on the server for
the
| Web page to use, or will the Web page always and forever call in to
redecode
| the image each time?
| a. If so, I'd like to know my alternatives.
| b. If not, how do I know when to release that variable?
| 6. How do I find out when the XML file has been updated so that I know to
| update the Application variable?
|
| I think that about covers it. If I think of anything else related to this
| scenario, I'll do a followup post.
|
| Thanks ahead of time for your help!
|
| --
| Greg Collins [InfoPath MVP]
| Please visit: http://www.InfoPathDev.com
|
|
|
|
Nov 18 '05 #3

P: n/a
So if I understand you both correctly I could do the following (please excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML file, decode the entire list of images, placing each one into an array which is then stored in an Application Cache object in the Cache Collection. This object can be named and referenced using the absolute path of the URL to the XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the XML file itself so that when the XML file is modified, the Cache object is automatically removed from the Collection, thus signaling me to reload the file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple. Well, the Cache is a specialized type of Collection, but it is, underneath the specialization (extra methods, fields, etc) a Collection. They are, in essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO processing and the processing involved in reading the XML from the file into an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application collections. if memory usage gets high, entries in the cache will automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've never run into one. And I have put a LOT of data in the Cache before (dozens of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max amount of memory asp.net will use (usually 60% of real memory). if asp.net goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the Web page to use, or will the Web page always and forever call in to redecode the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are cached. How do you know when to release that variable? Well, it's not a variable, it's a member object of a Collection. Using the Cache, you can tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you can do that as well. No harm done. When the Application ends, the Collection is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder containing the files, and have it respond to them. You could even cache the FileSystemWatcher, so that it resides in the Application and works for the lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on the file, and the cache will release the object automatically if the file is changed.

Nov 18 '05 #4

P: n/a
Those steps seemed to work. I have it all implemented and working as I described!

Thank you all for your help! I might not have been able to do it without your knowledge and suggestions!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML file, decode the entire list of images, placing each one into an array which is then stored in an Application Cache object in the Cache Collection. This object can be named and referenced using the absolute path of the URL to the XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the XML file itself so that when the XML file is modified, the Cache object is automatically removed from the Collection, thus signaling me to reload the file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple. Well, the Cache is a specialized type of Collection, but it is, underneath the specialization (extra methods, fields, etc) a Collection. They are, in essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO processing and the processing involved in reading the XML from the file into an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application collections. if memory usage gets high, entries in the cache will automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've never run into one. And I have put a LOT of data in the Cache before (dozens of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max amount of memory asp.net will use (usually 60% of real memory). if asp.net goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the Web page to use, or will the Web page always and forever call in to redecode the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are cached. How do you know when to release that variable? Well, it's not a variable, it's a member object of a Collection. Using the Cache, you can tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you can do that as well. No harm done. When the Application ends, the Collection is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder containing the files, and have it respond to them. You could even cache the FileSystemWatcher, so that it resides in the Application and works for the lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on the file, and the cache will release the object automatically if the file is changed.

Nov 18 '05 #5

P: n/a
Yes. I would use a cahe dependency, as bruce suggested. If you do, you don't
want to store all the SML files as a single array. You would cache each
individually. If the file changes, the cached object is removed. You would
therefore have to include code that checks to see whether the particular XML
file is cached before attempting to get it. If it is cached, it is fetched
from the cache. If not, the file is opened, parsed, and put into the cache,
and THEN it is fectched from the cache.

I would also recommend that you only cache each XML file as needed, since
they will be removed individually, and must be replaced individually. IOW,
wait until you receive a request for a given XML file prior to caching that
one file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please
excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML
file, decode the entire list of images, placing each one into an array which
is then stored in an Application Cache object in the Cache Collection. This
object can be named and referenced using the absolute path of the URL to the
XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the
XML file itself so that when the XML file is modified, the Cache object is
automatically removed from the Collection, thus signaling me to reload the
file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image
from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application
collections. if memory usage gets high, entries in the cache will
automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max
amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you
can do that as well. No harm done. When the Application ends, the Collection
is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on
the file, and the cache will release the object automatically if the file is
changed.
Nov 18 '05 #6

P: n/a
Yep! Right on top of that one! I had the same thoughts!

Thanx for sharing that info... it helps a lot! And it makes me feel like I'm actually starting to understand a little of this.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Kevin Spencer" <ks******@takempis.com> wrote in message news:OA**************@TK2MSFTNGP15.phx.gbl...
Yes. I would use a cahe dependency, as bruce suggested. If you do, you don't
want to store all the SML files as a single array. You would cache each
individually. If the file changes, the cached object is removed. You would
therefore have to include code that checks to see whether the particular XML
file is cached before attempting to get it. If it is cached, it is fetched
from the cache. If not, the file is opened, parsed, and put into the cache,
and THEN it is fectched from the cache.

I would also recommend that you only cache each XML file as needed, since
they will be removed individually, and must be replaced individually. IOW,
wait until you receive a request for a given XML file prior to caching that
one file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please
excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML
file, decode the entire list of images, placing each one into an array which
is then stored in an Application Cache object in the Cache Collection. This
object can be named and referenced using the absolute path of the URL to the
XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the
XML file itself so that when the XML file is modified, the Cache object is
automatically removed from the Collection, thus signaling me to reload the
file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image
from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application
collections. if memory usage gets high, entries in the cache will
automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max
amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you
can do that as well. No harm done. When the Application ends, the Collection
is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on
the file, and the cache will release the object automatically if the file is
changed.
Nov 18 '05 #7

P: n/a
Actually I do have a question. I think I know the answer, but I need to be absolutely sure.

Currently I'm using Cache.Insert() -- Is this an Application level or Session level Cache? As far as I can tell there's only 1 Cache object and it's Application level, but if I'm misguided on that, I want to make sure I'm using the Application Cache and not the Session Cache.

Thanx again in advance!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com

"Kevin Spencer" <ks******@takempis.com> wrote in message news:OA**************@TK2MSFTNGP15.phx.gbl...
Yes. I would use a cahe dependency, as bruce suggested. If you do, you don't
want to store all the SML files as a single array. You would cache each
individually. If the file changes, the cached object is removed. You would
therefore have to include code that checks to see whether the particular XML
file is cached before attempting to get it. If it is cached, it is fetched
from the cache. If not, the file is opened, parsed, and put into the cache,
and THEN it is fectched from the cache.

I would also recommend that you only cache each XML file as needed, since
they will be removed individually, and must be replaced individually. IOW,
wait until you receive a request for a given XML file prior to caching that
one file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:#V**************@TK2MSFTNGP09.phx.gbl...
So if I understand you both correctly I could do the following (please
excuse my lack of .NET experience and correct anything you need to):

1. The first time the decodeImage.aspx page is hit for a particular XML
file, decode the entire list of images, placing each one into an array which
is then stored in an Application Cache object in the Cache Collection. This
object can be named and referenced using the absolute path of the URL to the
XML file being decoded (minus any forbidden characters).

2. I can somehow create a link between the Application Cache object and the
XML file itself so that when the XML file is modified, the Cache object is
automatically removed from the Collection, thus signaling me to reload the
file, decode the images again, and recreate the Cache object.

3. Any subsequent requests for an image would grab the appropriate image
from the image array Cache object and return it to the calling Web page.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
========================================
1. Can I store the XmlNodeList object and restore it for use the next time?
a. If not, is there any advantage to storing the XML in the variable
over having it reloaded?

---KEVIN---------------------------
The Application and Application Cache are Collections, pure and simple.
Well, the Cache is a specialized type of Collection, but it is, underneath
the specialization (extra methods, fields, etc) a Collection. They are, in
essence, Name and Object Collections.

As everything in .Net is an object, you can store anything in these
Collections, and use them just as you would any object in any Collection.

The advantage of storing your XML in the Collection is the saving of IO
processing and the processing involved in reading the XML from the file into
an object. So, yes, there is an advantage in terms of performance.

---BRUCE---------------------------
there is one difference between the application cache and the application
collections. if memory usage gets high, entries in the cache will
automatically be removed.
========================================
2. What is the max size for an Application variable?

---KEVIN---------------------------
AFAIK, there is no maximum size, other than memory capacity. At least, I've
never run into one. And I have put a LOT of data in the Cache before (dozens
of MB).
========================================
4. What actually happens when that size limit has been reached?

---KEVIN---------------------------
I would imagine an "out of memory" exception, but that's just a guess.

---BRUCE---------------------------
if you look in machine.config/web.config, there is a setting for the max
amount of memory asp.net will use (usually 60% of real memory). if asp.net
goes over this number, its recycled (this will lose inproc sessions).
========================================
5. Once each image have been decoded, are they cached on the server for the
Web page to use, or will the Web page always and forever call in to redecode
the image each time?
a. If so, I'd like to know my alternatives.
b. If not, how do I know when to release that variable?
---KEVIN---------------------------
If you put them into a Collection, such as Application or Cache, they are
cached. How do you know when to release that variable? Well, it's not a
variable, it's a member object of a Collection. Using the Cache, you can
tell the Cache when to remove the object, or you can remove it yourself.

If these XML documents are needed for the lifetime of the Application, you
can do that as well. No harm done. When the Application ends, the Collection
is automatically released.
========================================
6. How do I find out when the XML file has been updated so that I know to
update the Application variable?
---KEVIN---------------------------
You could use a FileSystemWatcher to watch for changes in the folder
containing the files, and have it respond to them. You could even cache the
FileSystemWatcher, so that it resides in the Application and works for the
lifetime of the Application.

---BRUCE---------------------------
If you use the application cache object you can place a cache dependency on
the file, and the cache will release the object automatically if the file is
changed.
Nov 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.