471,627 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Momory usage with static methods

Hello:

We have an application that generates a static database layer based on
stored procedures defined in SQL Server for consumption by client
applications. These classes contain a slew of static methods. In many
cases you only need to use 4 or 5 of these to retrieve/update data from
the db. It seems like a collasal waste to have all of these excess
static methods hanging around. When are these static methods loaded
into memory? What is the memory impact of having these methods defined
but not used in an application namespace?

Thanks,
Tom

Feb 9 '06 #1
2 1364
tc****@gmail.com wrote:
We have an application that generates a static database layer based on
stored procedures defined in SQL Server for consumption by client
applications. These classes contain a slew of static methods. In many
cases you only need to use 4 or 5 of these to retrieve/update data from
the db. It seems like a collasal waste to have all of these excess
static methods hanging around. When are these static methods loaded
into memory? What is the memory impact of having these methods defined
but not used in an application namespace?


Usually, methods are only JITted when they're first used. I'd *hope*
that until that time, they're just in a memory mapped file against the
assembly. However, even if they're not - just how many methods are
there? I'd expect data to exceed code by a significant margin in pretty
much all applications.

Jon

Feb 9 '06 #2

<tc****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
| Hello:
|
| We have an application that generates a static database layer based on
| stored procedures defined in SQL Server for consumption by client
| applications. These classes contain a slew of static methods. In many
| cases you only need to use 4 or 5 of these to retrieve/update data from
| the db. It seems like a collasal waste to have all of these excess
| static methods hanging around. When are these static methods loaded
| into memory? What is the memory impact of having these methods defined
| but not used in an application namespace?
|
| Thanks,
| Tom
|

They are loaded with the assembly and JIT compiled when first called, so
there is no difference between static and non-static methods at this point.
The only difference is the static data member, they stay in memory for the
lifetime of the AD to which they belong.
You can save some space (taken by the MSIL) when you NGEN the assemblies.

Willy.
Feb 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

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.