Nhibernate Uses A Lot Of Memory?
Feb 9, 2011
I've got fluent nhibernate in my application and I'm trying to locate the cause of high memory usage. (I say high, it's 60MB, but it's a web app and it's not very big) Unfortunately it looks like a lot of it is in unmanaged memory, so I started taking things out - and as soon as I took out any calls to nhibernate, the memory usage dropped to 11MB!! Why oh why would it be taking up so much memory? Especially, why would it be taking up unmanaged memory?
I've been 'Googling' this all day and all I can find are posts from people saying "NHibernate eats memory..." and answers that say "no it doesn't, there's no evidence". Are NHibernate people in denial about it?
View 1 Replies
Similar Messages:
Jul 6, 2010
How can I write a unit test for CRUD using in memory database with fluent nhibernate
View 2 Replies
May 21, 2010
I am building an asp.net application, using II6 on windows server 2003 (vps hosting).
I am confronted with an error I didn't receive on my development machine (windows 7, iis 7.5, 64 bit).
When my wcf service tries launching my query running against a local sql server this is the error I receive:
Memory gates checking failed because the free memory (43732992 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
View 1 Replies
Oct 11, 2010
I have both VS 2005 and 2008 installed on my machine. 2005 is fine. For 2008, literally any asp.net project I try to create gets this eror. I try stepping into the code, and the error occurs apparently before anything that I can trap is loaded. There is no information written to the event log. I have tried this with a "Hello World" webpage with nothing else going on. Seems unique to my Windows Server 2003 machine.
View 3 Replies
Jul 30, 2010
I am getting a weird error in asp.net while using leadtools imaging api. Here's the stack trace.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at SetThreadData(_THREADDATA* )
at Leadtools.Codecs.CodecsOptions.Use()
at Leadtools.Codecs.RasterCodecs.DoSave(SaveParams saveParams)
at Leadtools.Codecs.RasterCodecs.Save(RasterImage image, Stream stream, RasterImageFormat format, Int32 bitsPerPixel)........
View 1 Replies
Jan 26, 2011
I am maintaining C# .NET code written by somebody else, I get following exception few times,Attempted to read or write protected memory. This is often an indication that other memory is corruptThe code structure where I get the above exception is somethign like this,- it is using ref variables in following sequence,Variable-1 and variable-2 are local variables in App1, - App1: func1() which passes these variables reference to func2(), - App1: func2() passes same variables reference via .net remoting to another application (App2).-App2: does the same passes same received reference to another call 2 times.- The execption is occured while returning from App2.
(App1:func1(ref Var1, ref Var2) --> App1:func2(ref Var1, ref Var2) <---App1 .net remoting to App2--> App2:func3(ref Var1, ref Var2)--> App2:func4(ref Var1, ref Var2)-->variables getting updated and function returned to original caller)
My doubts are ,1. Is passing reference variables in such chain is correct? will it cause such exeption? Does .net support ref variable call directly?
View 1 Replies
Jul 27, 2010
I have a memory leak somewhere that I cant find. Every few days my server will crash, and just before that I log a ton of SQL errors stating that it is "out of memory".
I cant find it anywhere, all of my connections are being disposed like so:
[Code]....
Then I call the connection from my pages like so:[Code]....
That is all pretty straight forward. The connection is disposed because it is implementing the USING clause. I am opening the connection in my connection manager class, and not where it is being utilized?Or, could the problem be in the below method I am using to populate a SqlDataReader:[Code]....
Now, at first it appears as though this could be the problem because the Connection isn't part of a USING clause, however doesn't the 'Data.CommandBehavior.CloseConnection' pretty much do the same thing. This makes sure that the connection is closed when the reader is closed, right? Here is how I call that above reader from my login page code behind:[Code]....
So the DataReader will get closed even without the .Close() because it is in the USING, and the connection should get closed because I specified it in the ExecuteReader paramters right?
View 8 Replies
Aug 24, 2010
I have a memory issue on my websites and am trying to get to the bottom of it. I have downloaded the 14 day trial of ANTS Memory Profiler and have been playing with it to get a grip of what it's telling me. In the memory options on the timeline, I can see Bytes in All Heaps and Private Bytes etc but I am not sure which ones I should be focusing on to see where the memory spikes and doesn't go back down.I am profiling a ASP.NET website using ASP.NET 2.0.
View 1 Replies
Aug 27, 2010
I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on Google but couldn't find the complete explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.
View 4 Replies
Aug 12, 2010
I am about to give up on this pos...unless somebody here simply gives me the right code to fix my problem. I'm tired of running in circles, and scouring the internet with no progress at all.
Problem: not updating collections with FK's.
Example:
Forum forum = new Forum("Sample");
category.AddForum(forum);
categoryRepository.Update(category); <- fails with transient object error for forum with no CategoryId.
Mapped right using References<Category> and HasMany<Forum>. Conventions are as follows.
Ref:
instance.Column(instance.Property.Name + "Id");
HasMany:
instance.Key.Column(instance.EntityType.Name + "Id");
instance.Cascade.All();
instance.Access.ReadOnlyPropertyThroughCamelCaseField(CamelCasePrefix.None);
Now, I've tried every possible setting for inverse, all the different cascades, on both sides. Nothing works. It just flat fails, telling me it can't insert NULL for Forum.CategoryId (field, not entity prop).
View 8 Replies
Nov 12, 2010
I've been reading up on DDD a little bit, and I am confused how this would fit in when using an ORM like NHibernate. Right now I have a .NET MVC application with fairly "fat" controllers, and I'm trying to figure out how best to fix that. Moving this business logic into the model layer would be the best way to do this, but I am unsure how one would do that.
My application is set up so that NHibernate's session is managed by an HttpModule (gets session / transaction out of my way), which is used by repositories that return the entity objects (Think S#arp arch... turns out a really duplicated a lot of their functionality in this). These repositories are used by DataServices, which right now are just wrappers around the Repositories (one-to-one mapping between them, e.g. UserDataService takes a UserRepository, or actually a Repository). These DataServices right now only ensure that data annotations decorating the entity classes are checked when saving / updating.
In this way, my entities are really just data objects, but do not contain any real logic. While I could put some things in the entity classes (e.g. an "Approve" method), when that action needs to do something like sending an e-mail, or touching other non-related objects, or, for instance, checking to see if there are any users that have the same e-mail before approving, etc., then the entity would need access to other repositories, etc. Injecting these with an IoC wouldn't work with NHibernate, so you'd have to use a factory pattern I'm assuming to get these. I don't see how you would mock those in tests though......................
View 3 Replies
Aug 10, 2010
I am using NHibernate in my web application. I need to use Convert() method in NHibernate query in order to get the date format as "MM/DD/YYYY".
I have used the below query using NHibernate query SELECT DISTINCT Convert(varchar(10),CurrentDate,101) AS Date FROM table order by Date desc.
But getting error.
Even I tried using views without unique key but Entity requires primary key.
View 2 Replies
Feb 1, 2010
I am working on NHibernate with oracle in ASP.Net. Now i am trying TDD(Test Driven Development). Can you tell me the best way to develop the TDD for NHibernate with oracle?I am using MbUnit with microdesk but it is not better approach for oracle but SQL server.
View 1 Replies
Nov 28, 2010
Using NHibernate with ASP.NET 4.
I have had no issues retrieving objects, but I've just got to a point with nested objects that I can't figure out.
I am using lazy=true and when accessing a lazy-load collection I get the message:
Initializing[type#3]-failed to lazily initialize a collection of role: [type], no session or session was closed
Even if I call SessionFactory.OpenSession() immediately prior to the object being accessed, it makes no difference. I have also tried accessing the collection in a using ISession block to no luck.
Edit to add - I do have current_session_context_class = web set in web.config, and I am using CurrentSessionContext.Bind on BeginRequest.
Not an MVC app
I read this - don't know how accurate it is, and it is Hibernate:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2878
It says something about a bug in many-to-many relationships.
Here is my HBM mapping:
<bag name="Objects" table="ObjectInstance" cascade="all" lazy="true">
<key column="branchId" />
<many-to-many class="InventoryObjectInstance" column="objectInstanceId" />
</bag>
View 3 Replies
Jan 28, 2011
A comment from .Net Hosting (Flexible Medium Trust) says.
Godaddy is medium trust, which means that u can't use stuff like IL emit(Nhibernate needs this for proxying)
Is it true? Is there anyone using NHibernate on GoDaddy?
View 2 Replies
Jul 8, 2010
I am a newcomer to NHibernate and know a bit about WCF. I would like to know how they best play together.Should I make the session per request? Or is there some different tactic that I should be using? What about the lifetime?Where do I set up my sessionfactory? In the global.asax?Can I best create a custom httpmodule or a new servicehostfactory to plug all the goods in?
View 2 Replies
Sep 6, 2010
No records where inserted in my SQL Table after committing the transaction or after the .Flush() method. I checked the code and it follows the correct sequence of codes. I can't seem to find any other way where the error fails.
View 3 Replies
Oct 20, 2010
How can we map a table without having primary key in nHibernate.I have a table which does not contain any primary key, so how can i map this table in .hbm.xml file.
View 1 Replies
Nov 30, 2010
how to implement codesmith in nhibernate.
View 1 Replies
Jan 21, 2010
Im currently starting on a project where im using NHibernate for dealing with the DB interactions, and MVC2 (RC) for the front end... and im just wondering if there are any decent tutorials on how to minimize the amount of duplicated validation that needs to be entered to validate thigns in NHibernate and try to mirror those constraints client side.. Ive looked at xVal which looks great, but i cant seem to get it to work and there dont seem to be that many articles about it. Also alot of people are mentioning that its going to become redundant at the MVC level in MVC2 due to the data annotation validation. So im really just after some more information/advice and links on the subject really...
View 2 Replies
Feb 16, 2011
I have a table USERS and GROUPS table.
I want to add another table UserGroups.
How can I map these tables.
View 1 Replies
Dec 10, 2010
I'm designing my first asp.net web app, using nHibernate as the data provider. i've read a lot about nhibernate in web applications using session-per-request pattern. my application will have a few pages which are 'monitors', meaning- they're updated automatically every few seconds to reflect recent changes to data. in that case, my thought is that opening a session for every request would not make much sense, since I know that an identical request is sure to follow in a few seconds. my thought is that session-per-conversation would make more sense for me, but I'm having trouble finding examples of implementations. I'd appreciate any good resources for how to implement session-per-conversation
View 2 Replies
Feb 12, 2010
I have an ASP.NET v2 website which uses NHibernate for ORM. My current architecture is not that great and I will be changing it after reading some best practices but I wish to still try and figure out my current problem. I have a login screen which creates a ISessionFactory with the connection string set appropriately to the user name and password entered. The SessionFactory is then stored in HttpRuntime.Cache (all objects stored in the HttpRuntime.Cache have an expiration of 30 minutes which is not ideal and may cause issues but hopefully is not relevant to this particular case).
Whenever a data query is made the application tries to retrieve a Session from HttpContext.Current. The first time this occurs no Session is present so one is created from the SessionFactory and stored for future reference. The same Session is therefore is used throughtout the application which is not ideal I believe and it is not explicity closed after each operation. There have been various issues with the application including timeouts which may be associated with not closing connections after each operation. An error that has recently appeared is:
Message: Login failed for user 'myusername'.
Type: System.Data.SqlClient.SqlException
Source: .Net SqlClient Data Provider
Stack Trace: at
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
This is only after a few minutes of using the application so should not be related to the use of HttpRuntime.Cache. The username in the exception (myusername) does not match the user specified in the connection string! Does anyone have any idea of what could cause this. I was thinking of ConnectionPooling but understand that the connection is made from a pool keyed on user name and password so it shouldn't confuse users. I am changing the application to use an IHttpModule to create a session per request which will be explicity closed after each operation but I would still like to know what causes the current problem.
View 1 Replies
Jan 21, 2011
I have a 'Photo' class and a 'Comment' class. An Photo can have multiple comments assigned to it.I have this configured as a one-to-many relationship within my HBM mapping file, and have set cascade="all-delete-orphan" against the 'Comments' bag within the Photo.hbm.xml mapping file.
However, if I try to delete a Photo which has 1 or more Comments associated with it, I am getting 'The DELETE statement conflicted with the REFERENCE constraint "FK_Comments_Photos"'
I tried a couple of other cascade options against the Comments bag in my Photo.hbm.xml but regardless of what I set it to, I'm getting the same outcome each time. I just want to be able to delete a Photo and have any associated comments automatically delete too.
Here is my Photo mapping (edited for brevity):
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" .... default-access="property" default-cascade="none" default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="Photo" table="Photos">
<id name="PhotoId" unsaved-value="0">[code]....
Here is my Comment mapping (edited for brevity):
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ... default-access="property" default-cascade="none" default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="Comment" table="Comments">
<id name="CommentId" unsaved-value="0">[code]...
why the cascade is not happening when I try to delete a Photo with comments associated with it?
UPDATE: The only way I can get the cascade to happen is to configure the 'Delete Rule' within SQL Server against this relationship to 'Cascade', and in doing so means that I don't need to specify any cascade action within my NHibernate Mapping. However, this isn't ideal for me - I'd like to be able to configure the cascade behaviour within the NHibernate Mapping ideally, so I'm still confused as to why it doesn't appear to be taking any notice of my NHibernate cascade setting?
View 2 Replies
May 11, 2010
I have a table defnition as given below:
License
ClientId
Type
Total
Used[code]....
If a client used a license to create a user, I need to update the Used column in the table. As I set ClientId column as the id column for this table in the mapping xml, I am getting TooManyRowsAffectedException. how to set a composite key at mapping level so that NHibernate can udpate based on ClientId and Type.
Something like: Update License SET Used=Used-1 WHERE ClientId='xxx' AND Type=1
View 3 Replies