|
GlobalMemoryStatus(out stat);
usrSysInfo.totalPhysicalMemory =(UInt32)IPAddress.NetworkToHostOrder((int)stat.TotalPhysical);
tempArray = BitConverter.GetBytes(usrSysInfo.totalPhysicalMemory);
SysInfoMemStream.Seek(offset, SeekOrigin.Begin);
SysInfoMemStream.Write(tempArray, 0, sizeof(UInt32));
offset += sizeof(UInt32);
I am converting the data to NetworktoHostOrder and convert to byte and trasfer it to the server. Server will do reverse process and get the actual data..
I dont know how the RAM value is in negative.
Similary i want to know whether the GLobalMemoryStatusEx method returns the actuall RAM isntalled in the machine or the RAM available to the users.
|
|
|
|
|
Hi,
GLobalMemoryStatusEx returns physical memory, with a few MB deducted for unknown reasons (same thing occurs in Task Manager, it shows 3069MB for 3GB !)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
but why its returning negative junk value instead of -1 ???
|
|
|
|
|
If a function returns a value you don't like, the most likely cause is you did something wrong. In this case, did you set the Length member of the struct correctly? It is different for
MemoryStatusEx!
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
i am using like this (in C# code)
stat.Length = Marshal.SizeOf(stat);
because it is not accepting
stat.Length = sizeof(stat);
will it give the correct length of the MemoryStatus
|
|
|
|
|
if you doubt it, then check it; why would you need or want spoon feeding?
You can see how large the struct is from its definition, and you can watch the value you assign to Length.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
sorry , will set the actual value.
why i asked is i tried using Marshall.sizeof function once. it doesnt work proeprly for me. so i took the size by counting the size of every variable in a struct
|
|
|
|
|
sizeof and Marshal.SizeOf may return different values, they do represent different things.
sizeof is the size as a managed object, Marshal.SizeOf is the size when marshaled to the native world.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
CoolCoder_New wrote: =(UInt32)IPAddress.NetworkToHostOrder((int)stat.TotalPhysical);
I knew it was something you did... There's where the negative number is coming from. You converted stat.TotalPhysical to a signed integer, instead of leaving it unsigned.
|
|
|
|
|
but i am converting NetworkToHostOrder to UInt32 right ??
NetWorkToHostOder accepts only int , long , short of C# datatype. tahts why i have converted it to int.
Oh will the uint to int creates negative value ???
|
|
|
|
|
CoolCoder_New wrote: will the uint to int creates negative value ???
there is a 50% probability they do.
have you any idea how the number representation works?
half of the Uint32 numbers have their highest bit set indicating a value >= 2GB
when looking at the same bit pattern as an Int32 it will be negative.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
let me check the server side code and check how these values got converted.
Thanks you to both of you.
i have learnt more
|
|
|
|
|
I can't for the life of me work out how to implement this in f#
protected override IEnumerable<shapedef> GetShapeDefinition()
{
// Yield out a Box2D shape definition
PolygonDef def = new PolygonDef();
def.VertexCount = 3;
def.Vertices[0] = new Vector2(0f, 6f);
def.Vertices[1] = new Vector2(-2f, -3f);
def.Vertices[2] = new Vector2(2f, -3f);
def.Restitution = 0f;
def.Friction = 1f;
def.Density = 1f;
yield return def;
}
The closest I've come is this
override x.GetShapeDefinition = seq<shapedef>{
let def = new PolygonDef()
def.VertexCount <- 3
def.Vertices.(0) <- new Vector2(1.0f, 2.0f)
def.Vertices.(1) <- new Vector2(-2.0f,-3.0f)
def.Vertices.(2) <- new Vector2(2.0f,-3.0f)
def.Restitution <- 0.0f
def.Friction <- 1.0f
def.Density <- 1.0f
yield (def :> ShapeDef)
}
But I get
No abstract property was found that corresponds to this override. (FS0191) - C:\Users\Matthew\Documents\SharpDevelop Projects\FSharpGame\FSharpGame\Ship.fs:20,14
|
|
|
|
|
Got it to work;
override this.GetShapeDefinition() = seq<shapedef>{
let def = new PolygonDef()
def.VertexCount <- 3
def.Vertices.[0] <- new Vector2(1.0f, 2.0f)
def.Vertices.[1] <- new Vector2(-2.0f,-3.0f)
def.Vertices.[2] <- new Vector2(2.0f,-3.0f)
def.Restitution <- 0.0f
def.Friction <- 1.0f
def.Density <- 1.0f
yield (def :> ShapeDef)
}
|
|
|
|
|
|
This isn't a project yet, it's a wishlist - have you started on a project-plan?
I are troll
|
|
|
|
|
I have created Abc.msi File using setup and Deployment from Visual Studio 2008. I would like to test this in vertual machine before installing to a client machine. I followed these procedures
1. install .net framework 3.5 on Virtual Machine
2. then install Abc.msi
I gets installed perfectly fine but when I try to open that it Gives me error saying that --
"Abc" encountred some problem. How can I overcome this problem? Any help will be appreciated.
In that winform I have one of the function "print" that prints in Excel file. Vertual machine does have office 2007 installed.
Thank you
bijaya
|
|
|
|
|
If you're using the Office interop, then you'll have to have Excel installed.
Use the Assembly Binding Log Viewer[^] to make sure that missing assemblies is the problem that you're encountering.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I have Excel installed in the vertual machine.
Thank you
Bijaya
|
|
|
|
|
What are the differences between singleton and pooling?
If singleton design pattern is used to have just one connection.
Also, we know that the connection pooling helps to organise the connections.
How are hese two things similar and different?
Many Thanks....
|
|
|
|
|
A Singleton implementation should guarantee that there is ONE AND ONLY ONE instance of a particular object in a system.
A pool is a management object that contains resources. It is generally used to maintain high-cost connections to resources and limit the number of the resources generated by the system.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Can we have a practical explanation of that? More elaborate...
t.a.
|
|
|
|
|
Sure.- Singleton Example
- Let's say that you're implementing an interpreter for a scripting language that contains some mathematical operators. Now, you design your language so that none of the objects that implement the operators (such as AddOperator, MultOperator) have state, just a collection of methods. To reduce the memory consumption of the interpreter, you can choose to have each of those operators as singletons, one instance of the AddOperator will exist in any AppDomain. This is in contrast to parsing the input and creating an AddOperator into an abstract syntax tree every time the parser encounters the + symbol.
- Pool Example
- Quite often in multi-threaded applications that access data from a persistent store, the connections that the applications use to connect to the persistent store are pooled. For example, it's a common practice to pool a certain number of connections to a database because it's so darn expensive to create the connection. Then, when an application wants to get data from the database, it asks the pool for a connection instead of creating its own.
I think that your confusion may be coming from the thought that "a resource pool is a singleton." That can be true and quite often is. In general, why would you create multiple pools of resource connections when that kind of defeats the purpose of having that limited number of expensive connections?
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanks for explanation.
However, could you please select another example.
Call me a dumbo, but i am in a loss of differentiating between the two.
For example, if i have a web application where there are 7 odd connections strings. Do i hav to use the Singleton or just use Pooling to take care of that?
You are already writing good and helping my understanding.
Appreciate Much!
|
|
|
|
|
In general, why would you create multiple pools of resource connections when that kind of defeats the purpose of having that limited number of expensive connections?
Designing an architecture around singleton objects that hold state may lead to problems if requirements change in unexpected ways. Even if it's expected that the singleton will be associated with a hardware resource of which there will never be more than one (e.g. the current display monitor) it's possible that there may in future be a need to support more than one such resource, no matter how unlikely it may seem today.
That having been said, the proper type of object is something like a singleton, in that at most one such object should be associated with any particular hardware resource, and the object should persist as long as anyone has use for it.
There are other pooling situations, like thread pools, where sharing one pool between different parts of an application may lead to resource starvation. While there may be ways of having a single pool implement a suitable prioritization strategy to ensure that every separately-designated part of an application is allowed to have at least one thread running at a time from a shared pool, having different parts use different pools may be simpler.
|
|
|
|