|
Hi all,
i am retrieving total physical memory using GlobalMemoryStatus() as follows :
public struct MemoryStatus
{
public uint Length; //Length of struct
public uint MemoryLoad; //Value from 0-100 represents memory usage
public uint TotalPhysical;
public uint AvailablePhysical;
public uint TotalPageFile;
public uint AvailablePageFile;
public uint TotalVirtual;
public uint AvailableVirtual;
}
MemoryStatus stat;
[DllImport("kernel32.dll")]
public static extern void GlobalMemoryStatus(out MemoryStatus stat);
GlobalMemoryStatus(out stat);
uint totPhy = stat.TotalPhysical;
My question is
1) Is the stat.TotalPhysical return the actual physical memory installed int he machine ?
2) I am getting neagtive value like -271691776 for the vista mahcine(Os type : 6.0.6001) and Windows Server 2000 .
Can someone please help me out.Thanks in advance
|
|
|
|
|
Hi,
I suggest you switch to GlobalMemoryStatusEx() and MemoryStatusEx (with "long" members)
since IIRC the old ones don't cope with memory sizes beyond 2GB.
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
|
|
|
|
|
On top of what Luc said, you say you got negative numbers?? How?? Since unsigned integers can't return negative numbers, you had to use some calculation that introduced them. This says that your methodolgy is wrong.
|
|
|
|
|
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.
|
|
|
|