Hy,

Let's say that I have class Node with some parameters Node[] child's, string id, string content ...
This class is like a another storage for data from mssql database.
And that web-application is running on IIS server and is written in ASP.NET C#

Now when one user open that page, certain data is dumped from db into that instance Node class depends on which sub-page user open.
And then another user open the same page and the same sub-page .. but again the same data is dumped into another instance of class Node.

What I want is to share that Node class between users, is that possible, so one user open the page and if no instance of Node class is made, new one is created, otherwise the same Node class is used and I'll use much, much less memory with the application :}

When a asp.net web page is accessed remotely by a user, IIS process the request and sends the output to the user. For processing the request, it may create some temprory variables based on the program logic that you have written. The temprory memory data will be cleared by .NET CLR once the response is sent to the client browser.

IIS will not store any data in memory unless you store data specific to users in Session. If you want to save memory, do not store values in Session, Application and Cache objects.

If you want to share the instance of a class in .NET, you need to implement Single Desig Pattern.

Check the following links.
Implementing Singleton in C#

Singleton Design Pattern

Implementing the Singleton Pattern in C#

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.