473,396 Members | 1,760 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,396 software developers and data experts.

Too many objects loaded at the same time and cause OutOfMemory exception.

I'm working on a .net web application. The architect of this web
application is quite different than other web applications i worked
before. Since we use a set of tools to generate most of the basic
code. Every table in the database related to an object in the
application. There is no stored procedures in database; In every
object of the application, the tool generates methods for basic
database operations like insert, delete, update, selete, and methods
to compose a select query inside the table(object)

But it definitly is a bad design, since we have more and more users,
big performance issues coming out when generating reports for users.
For example, if i use this architect for a school, i can easily create
objects of grade, class, student, lesson, semester, now let's say i
have 6 grades, each grade has 10 class, each class has 20 students,
each student has 5 lessons. If i want to generate a score report for
all students's score in fall of 2006, i have to first load grade
object collection, loop into grade collection; load class object
collection, loop into class collection; load student object
collection, loop into student collection; load lesson object
collection, loop into lesson collection. I don't know how .net garbage
collection will work on this situation, whether or not it does load
all 6x10x20x5=6000objects in memory at the same time. I noticed a huge
memory overhead for aspnet_ws process, then i got Service Unavailable
error in my browser, and the memory of aspnet_ws back to normal.

Does anyone know how .net framework works on my situation? Any
resolution to this OutOfMemory issue except using stored procedure? I
don't think asynchronized process will help, what do you think? What's
the best way to scale out for the current system?

thank you for your help,
-Elaine

Jan 30 '07 #1
2 1366
Elaine,
Stored procedures won't necessarily help here, they would simply
push the select and other data access mechanisms onto the database server,
though they will improve the speed of the queries slightly since they will
allow the database to pre-plan the implementation. Stored Procedures will
also drastically improve your security since they promote parametrized
queries and help avoid SQL Injection attacks. You're still stuck with the
application design overall. It seems to be a rather cumbersome design to say
the least. There should be a way to load objects without having to load all
of these collections. I think a better, more direct approach would need to
be taken. This would make sense if you were drilling down into a data
wherehouse and using a pivot table and incrementally loading data as needed.

The garbage collection should occur sometime after the page unloads.
You can attempt to speed it up by calling the dispose method on the
collections (if available) and then setting them to null. I don't think this
architecture will work very well as it doesn't sound very stable at all. You
should be able to create functionality to get this sort of data directly
from the db as there should be no need to call all these objects just get
the results of what should be a common type of sql query.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"elaine" <el*******@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
I'm working on a .net web application. The architect of this web
application is quite different than other web applications i worked
before. Since we use a set of tools to generate most of the basic
code. Every table in the database related to an object in the
application. There is no stored procedures in database; In every
object of the application, the tool generates methods for basic
database operations like insert, delete, update, selete, and methods
to compose a select query inside the table(object)

But it definitly is a bad design, since we have more and more users,
big performance issues coming out when generating reports for users.
For example, if i use this architect for a school, i can easily create
objects of grade, class, student, lesson, semester, now let's say i
have 6 grades, each grade has 10 class, each class has 20 students,
each student has 5 lessons. If i want to generate a score report for
all students's score in fall of 2006, i have to first load grade
object collection, loop into grade collection; load class object
collection, loop into class collection; load student object
collection, loop into student collection; load lesson object
collection, loop into lesson collection. I don't know how .net garbage
collection will work on this situation, whether or not it does load
all 6x10x20x5=6000objects in memory at the same time. I noticed a huge
memory overhead for aspnet_ws process, then i got Service Unavailable
error in my browser, and the memory of aspnet_ws back to normal.

Does anyone know how .net framework works on my situation? Any
resolution to this OutOfMemory issue except using stored procedure? I
don't think asynchronized process will help, what do you think? What's
the best way to scale out for the current system?

thank you for your help,
-Elaine

Jan 30 '07 #2

Hi Mark,
Thank you for your response.

First, I think Stored procedures will help me here, as you said in
your post "You
should be able to create functionality to get this sort of data
directly
from the db as there should be no need to call all these objects just
get
the results of what should be a common type of sql query. ", I think
stored procedure can do it for me. The reason i don't want to use
stored procedure here is this system is not small, each report might
need over 20 objects involved, i have to write complex stored
procedures. And besides reports, i think later on, other
functionalities might have the same issue as reporting, if i choose to
use stored procedures to feed all my need, it seems like i need to
rewrite the whole application.

I will try to add dispose method in the loops to see if this will
work.

I'm also interested in the way you mentioned "This would make sense if
you were drilling down into a data
warehouse and using a pivot table and incrementally loading data as
needed. ", can you give me some references to check about how to use
data warehouse in my case?"

Thanks again for your help.
-Elaine

On Jan 29, 5:05 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Elaine,
Stored procedures won't necessarily help here, they would simply
push the select and other data access mechanisms onto the database server,
though they will improve the speed of the queries slightly since they will
allow the database to pre-plan the implementation. Stored Procedures will
also drastically improve your security since they promote parametrized
queries and help avoid SQL Injection attacks. You're still stuck with the
application design overall. It seems to be a rather cumbersome design to say
the least. There should be a way to load objects without having to load all
of these collections. I think a better, more direct approach would need to
be taken. This would make sense if you were drilling down into a data
wherehouse and using a pivot table and incrementally loading data as needed.

The garbage collection should occur sometime after the page unloads.
You can attempt to speed it up by calling the dispose method on the
collections (if available) and then setting them to null. I don't think this
architecture will work very well as it doesn't sound very stable at all. You
should be able to create functionality to get this sort of data directly
from the db as there should be no need to call all these objects just get
the results of what should be a common type of sql query.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"elaine" <elain....@gmail.comwrote in messagenews:11**********************@h3g2000cwc.go oglegroups.com...
I'm working on a .net web application. The architect of this web
application is quite different than other web applications i worked
before. Since we use a set of tools to generate most of the basic
code. Every table in the database related to an object in the
application. There is no stored procedures in database; In every
object of the application, the tool generates methods for basic
database operations like insert, delete, update, selete, and methods
to compose a select query inside the table(object)
But it definitly is a bad design, since we have more and more users,
big performance issues coming out when generating reports for users.
For example, if i use this architect for a school, i can easily create
objects of grade, class, student, lesson, semester, now let's say i
have 6 grades, each grade has 10 class, each class has 20 students,
each student has 5 lessons. If i want to generate a score report for
all students's score in fall of 2006, i have to first load grade
object collection, loop into grade collection; load class object
collection, loop into class collection; load student object
collection, loop into student collection; load lesson object
collection, loop into lesson collection. I don't know how .net garbage
collection will work on this situation, whether or not it does load
all 6x10x20x5=6000objects in memory at the same time. I noticed a huge
memory overhead for aspnet_ws process, then i got Service Unavailable
error in my browser, and the memory of aspnet_ws back to normal.
Does anyone know how .net framework works on my situation? Any
resolution to this OutOfMemory issue except using stored procedure? I
don't think asynchronized process will help, what do you think? What's
the best way to scale out for the current system?
thank you for your help,
-Elaine- Hide quoted text -- Show quoted text -
Jan 30 '07 #3

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

Similar topics

3
by: Mike Schilling | last post by:
Instances of SystemOutOfMemoryException do not contain a stack trace. Easy test to verify this: class OOM { public static void Main() { try { Object arr = new Object; } catch...
38
by: Radi Radichev | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
2
by: Ricky Chan | last post by:
Windows Server 2003 with 2G Ram ,IIS6 -> I have enabled /3gb switch in boot.ini ! -> Machine.config set to 80% memory Limit However, It still throw outofmemory exception when loading large...
1
by: Ricky Chan | last post by:
In the production environment, it always occurs and the worker process did not recycle automatically. Therefore, it make the system service break to client. In development environment, we write...
2
by: Peter S. | last post by:
I am pulling some data from a source via ODBC and placing the information in a DataSet. The first pull is very large but once that is complete I plan to do nightly pulls to get any new data that...
3
by: Nemisis | last post by:
Hi everyone, Can someone please tell me why my code hits an "out of memory exception" on the below code? All the code does is load some documents from a SQL database and loop through a data...
4
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but...
5
by: Jonathan Boivin | last post by:
Hi, I've got some problems with loading bills using a bill usercontrol I built. If I load all current bills in my test environment (156) everything is fine once, but repeating the operation...
0
by: doobybug | last post by:
Hi all, I really need your help! I am new to java and have some problems with my code. I have a program which inputs questionnaires and creates an object for each questionnaire. These objects are...
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
0
BarryA
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...
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
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...
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
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...
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
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.