|
Thanks for the tip. I wasn't aware of that one. I'm sure that will help.
|
|
|
|
|
A side note - don't allocate more than about 85k of memory to any single object unless you're prepare to handle cleanup manually. Anything bigger than that gets shoved onto the "large object heap", and the GC doesn't clean that up for you.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Got that covered. All of my core logic I'm writing in unmanaged code. I found early on that I didn't like the overhead of some of the System.Collections.Generic classes -- especially the bulky disk usage in serialization compared to doing a straight binary write of unmanaged data structures. So I chose to write the app in C++/CLI, using .NET for the ease of creating Windows forms and controls while keeping my core logic and processing in native C++. So I'm fully prepared to do my unmanaged allocation and cleanup. Like I said, the behavior I'm calling into question occurs with things I have little or no control over, such as Menu controls and dialogs.
|
|
|
|
|
Hi John,
I don't fully agree, AFAIK objects on the large object heap are managed like all other
managed objects, with a single difference: the LOH does not get reshuffled, hence
there is a risk of fragmentation.
Example: allocate 1MB, then 100MB, repeat this N times until memory is almost full,
then throw away the references to all 100MB objects and try to get one really big
object of 300MB.
IMO the threshold (85KB?) is not documented, is not available through some API,
may vary over time, and may depend on your system's memory situation.
I feel the Framework should be more specific about this, it should guarantee a
reasonable minimum value for the threshold, so one can make sure fragmentation will
not become an issue by keeping objects smaller than that.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: the threshold (85KB?) is not documented, is not available through some API,
may vary over time, and may depend on your system's memory situation.
In general this is true, the 85KB limit isn't publicly documented. I did find it in Rotor[^] (SSCLI) in the gc.h header file for the garbage collector's native code:
#define LARGE_OBJECT_SIZE 85000 .
|
|
|
|
|
Hi,
I am amazed that after reading all the replies and posts on this article no one mentions of the Using...End Using code block.
I am sure you must be knowing it but just a little bit of detailing on the using statements:
'VB Version, C# no different, just lang. changes<br />
Using dlgOpen As New OpenFileDialog()<br />
dlgOpen.Filter="*.*" <br />
'Any other properties<br />
dlg.ShowDialog()<br />
End Using
Now what the above code fragment does is that the CLR will create the dlgOpen object and will be responsible for its disposal, not YOU.
This has serious benefits in terms of Performance & Memory Utilization since as soon as the code execution reaches End Using the dlgOpen will be Disposed off without requiring you to do any thing at all.
:::One Catch Though While using the Using statements:::
the dlgOpen will not be accessible outside the Using block since its scope is limited is to the Using...End Using block.
So i strongly recommend you to go ahead and use the Using...End Using blocks for all the DialogBoxes since most of them times they return only one value which can easily be stored on a local/global variable.
Awaiting reply eagerly.
Regards,
Vaibhav Sharma
|
|
|
|
|
I appreciate the tip. I am aware of the "using" syntax, but in my case that won't work. As I mentioned in my response to John Simmons's post above, my application is written in C++/CLI, which has no such construct. There were multiple reasons for that language choice, some of which I mentioned and others that are irrelevant to this conversation. And even if I was in C#/VB, I'd still have the same problem with the Menu control. Can't use "using" for something like a menu that has to be present for the duration of execution.
Regardless, I think it was one of Luc Pattyn's responses that directed me to try examining memory usage through the Environment.WorkingSet (thank's again, Luc). This provides memory use much closer to what I would expect based on my interaction with the application. I still find it alarming that the .NET virtual machine continues to eat up additional memory when it's not needed, but there I just have to trust that the GC will do its job when push comes to shove.
|
|
|
|
|
Hello. I hope these are some simple questions:
1. Is there a way to read an embedded resource out of a managed DLL without having to load the whole assembly?
2. If, as is my understaning, the answer to #1 is "NO", what is the point of embedding resources instead of loading your resources from individual files at run-time? In other words, if I have a DLL that contains 128MB of images, and I only want to extract a 64KB image from it, what is the point of embedding when I'd have to take the 128MB hit on my memory use -- especially when an assembly can't be unloaded?
Thanks for your input.
|
|
|
|
|
Hi,
AFAIK:
1. No
2a. You can make a single-file app that holds images, fonts, whatever.
2b. You can protect your data by putting it in as a resource (possibly using encryption).
2c. You can group things that belong together into a single DLL, have several of those
and load the one you need (e.g. language selection, regionalization)
2d. If you are that concerned about memory footprint, make smaller DLLs; at one resource
per DLL, it does not make much sense any more.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Good point. I had actually thought of the resource grouping as opposed to having a bundle of extra files. And I'm even OK with having to load the entire DLL to get a resource. It's the inability to unload the DLL that I don't like.
Maybe I'm still clinging to the old-school mentality of maximum memory conservation. I'm only 30 yrs old, but that still puts me at old enough to have had it beaten into my head in school about programming for minimal memory use and maximum efficiency.
Regardless, if I have data resources that need to be copied into memory for runtime manipulation, and the DLL can't be unloaded, well then I have two full copies of those resources resident in memory for the duration of execution. That seems wasteful, and that's what I can't stand about it.
|
|
|
|
|
If you really want to get rid of some DLL, load it in a separate AppDomain;
you can unload an AppDomain, which also frees all its code space.
There is a price to pay: you now have to communicate from one AppDomain to another.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi
i have a logging session which i use in the global.asax file which determines if the user is authenticated to the system
i ahve it working within reason
but if i try to access a page before logging in it will render page then will write my relogin page to the same page
I want it to redirect to this page relogin page if the user isn't authenticated on the system, so that nothing is showing by the browser
i have the following code
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
Session("loggedin") = "False"
CheckLoggedIn()
Session.Timeout = 20
End Sub
Sub Application_OnPostRequestHandlerExecute()
CheckLoggedIn()
End Sub
'Check that the user is logged in.
Sub CheckLoggedIn()
'If the user is not logged in and you are not currently on the Login Page.
If InStr(Request.RawUrl, "default.aspx") Or InStr(Request.RawUrl, "passwordrecover") And Session("loggedin") = "null" Then
ElseIf Session("Loggedin") = "False" Then
server.transfer("relogin.aspx")
ElseIf Session("Loggedin") = "True" Then
End If
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
Server.Transfer("relogin.aspx")
End Sub
I have also tryed using response.redirect, but this jus does the same in thing IE, and firefox will jus timeout everytime
any help appreciated
boyindie
|
|
|
|
|
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
just remove Session("loggedin") = "False" then try
else
just set Session("loggedin") = Null
CheckLoggedIn()
Session.Timeout = 20
End Sub
saniya khengar v
|
|
|
|
|
I have got it working now
but it doesn't allow null as its outdated, it will only allow a dbNull
but i just set it
session=""
works jus as well
|
|
|
|
|
Hi All,
I am familiar with vc++ and I want to learn vc++.net. So Can you plz suggest one good book at beginner level and one good book at middle level in vc++.net.
Rgds
trinadh
|
|
|
|
|
If you mean VC++.NET is C++/CLI (Managed C++), there are not many books to choose from. Here is my list from beginner to advance:
Beginner:
Pro Visual C++/CLI and the .NET 2.0 Platform, Stephen R. G. Fraser, Apress
C++/CLI The Visual C++ Language for .NET, Gordon Hogenson, Apress
Beginner/Intermediate:
C++/CLI in Action, Nishant Sivakumar, Manning
Intermediate/Advance:
Expert C++/CLI .Net for Visual C++ Progammers, Marcus Heege, Apress
The Hogenson book is for people who are new to C++/CLI but it reads better if you already have programming experience. IMHO, the easiest reading books are by Fraser and Sivakumar (a Code Project regular). Also, all these books are available in PDF format.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George L. Jackson wrote: Nishant Sivakumar
Where have I heard of that guy?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I have had the same deja vu feeling myself? Weird!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi all,
Actually i want the solution of the fact that i want to avoid the runtime environment installing by including those dll in the application installer required to run the application that is developed in the .net.
in nutshell , my question is how to avoid the whole .net framework runtime environment to run the application that is developed in .net. this is bcoz we dont want to install the .net framework 2.0 in our client machine even we have developed his product in .net platform.
Thank you in adavance
naresh is testing the site.
|
|
|
|
|
Thats not really a possible scenario I'm afraid. The framework isn't just a bunch of dlls that your application depends on.
Also I doubt Microsoft will legally allow you to redistribute any of the framework by hand - they give you the runtime merge module and the dotnetfx redistributable for a reason.
|
|
|
|
|
Thank you very much Mark for your information.
naresh is testing the site.
|
|
|
|
|
Hi Mark.
There is product called thinstall that is doing the job wat i was expecting ..is it illegal??
wat's ur view abt this software??
thank you
naresh is testing the site.
|
|
|
|
|
It's not illegal at all. Essentially, what Thininstall is doing is creating a customized virtual environment that your application runs in. From your application's point of view it is running with the full framework installed. The company has been around since 1999 and appears to have a well established client list, but the product is not cheap. The base price is $4995.00 USD plus distribution fees. To me, it's not worth the price.
|
|
|
|
|
Hi,
The solution you want is definitely feasible but costly.
Yes a .NET application can be deployed to the client machine without installing the complete .NET Framework. Yes and please dont ask me how because i dont have the answer.
But someone has the answer and its here:
Salamander .NET Linker and Mini Deployment Tool
As regards license issues with Microsoft i guess once you reach the above link you will find a key quote given by a Microsoft employee so rest assure it is not anti licensing as far as you are concerned.
But then it is not free and you will need to make sure you get it genuinely and it has great benefits by providing inbuilt obfuscation that prevents reverse engineering of .NET MSIL code, the biggest disadvantage of .NET Applications.
So best of luck and do reply, eagerly awaiting your comments.
Regards,
Vaibhav Sharma
|
|
|
|
|
Hello everybody,
I´ve a strange problem with WPF Animations.
The mouse will moved over an UserControl (screenshot white area) and the current mouse position will displayed in a pixelbar, displayed by a line at the current pixel position (screenshot orange arrows).
Screenshot link:
http://www.connectiongroup.de/other/scrollbars_export2.png[^]
The pixelbars are own UserControls, which gets the current mouse position over the MouseMove event by the white UserControl.
On my machine with windows vista it´s runs terrible slow, as far the mouse leaves the origin (0x, 0y) it will more stucks, likes on a 486 runinng quake.
Now then, here´s the joke: Under windows XP the same compiled wpf application runs without any problems or stuking. - but, why this?
I´ve tested the executeable on other vista machines, always the the same problem at all.
Anticipate: It´s a Core2Duo with 2.8 GHz and a GeForce 7800 - should actually run ...
Detailed information:
The projekt runs under visual studio 2008 beta 2, it´s a wpf application using 3.5 .NET framework.
I´ve observed in general that wpf animations runs very slow under vista, e.g. a simple rectangle opacity fadein and -out. With XP there´s no problem...
Whereby can this due to, has anyone such a similar problem, does anybody know this problem?
|
|
|
|
|