By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,272 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Simple code doesn't work on two systems

P: n/a
I wrote this very simple code in .NET VC++. I compiled it on my system, and
tried to run it on my friend's computer (he doesn't have the compiler). We both
have Windows XP Professional. I have .NET framework 2.0, and he had 1.0 and it
didn't work; then he installed 2.0 and it still didn't work; so he tried with
2.1 and it didn't work, then 3.0 and nothing still worked. I have Intel Centrino
Mobile (laptop computer), and he has Intel Pentium 4 (desktop computer). His
system reported an error that it cannot execute the program because of invalid
configuration. Why doesn't it work?

Here is the code I wrote, if it would mean anything:

#include <stdlib.h>

int main(void) {
int *a;
while (1) {
a = (int *) malloc(100000 * sizeof(int));
}
return 0;
}

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 17 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a

"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
>I wrote this very simple code in .NET VC++. I compiled it on my system, and
tried to run it on my friend's computer (he doesn't have the compiler). We
both have Windows XP Professional. I have .NET framework 2.0, and he had
1.0 and it didn't work; then he installed 2.0 and it still didn't work; so
he tried with 2.1 and it didn't work, then 3.0 and nothing still worked. I
have Intel Centrino Mobile (laptop computer), and he has Intel Pentium 4
(desktop computer). His system reported an error that it cannot execute the
program because of invalid configuration. Why doesn't it work?
Did you do a release compile? The debug compile in C++ requires debug
libraries that are only present when the compiler is installed.
>
Here is the code I wrote, if it would mean anything:

#include <stdlib.h>

int main(void) {
int *a;
while (1) {
a = (int *) malloc(100000 * sizeof(int));
}
return 0;
}

--
"It is easy in the world to live after the world's opinion; it easy in
solitude to live after our own; but the great man is he who in the midst
of the crowd keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 17 '07 #2

P: n/a
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...
>
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
>>I wrote this very simple code in .NET VC++. I compiled it on my system, and
tried to run it on my friend's computer (he doesn't have the compiler). We
both have Windows XP Professional. I have .NET framework 2.0, and he had 1.0
and it didn't work; then he installed 2.0 and it still didn't work; so he
tried with 2.1 and it didn't work, then 3.0 and nothing still worked. I have
Intel Centrino Mobile (laptop computer), and he has Intel Pentium 4 (desktop
computer). His system reported an error that it cannot execute the program
because of invalid configuration. Why doesn't it work?

Did you do a release compile? The debug compile in C++ requires debug
libraries that are only present when the compiler is installed.
Do you mean by going to Build->Compile in the menu (or pressing Ctrl+F7)? I did
that, but it doesn't work.

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 18 '07 #3

P: n/a

"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...
>>
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
>>>I wrote this very simple code in .NET VC++. I compiled it on my system,
and tried to run it on my friend's computer (he doesn't have the
compiler). We both have Windows XP Professional. I have .NET framework
2.0, and he had 1.0 and it didn't work; then he installed 2.0 and it
still didn't work; so he tried with 2.1 and it didn't work, then 3.0 and
nothing still worked. I have Intel Centrino Mobile (laptop computer), and
he has Intel Pentium 4 (desktop computer). His system reported an error
that it cannot execute the program because of invalid configuration. Why
doesn't it work?

Did you do a release compile? The debug compile in C++ requires debug
libraries that are only present when the compiler is installed.

Do you mean by going to Build->Compile in the menu (or pressing Ctrl+F7)?
I did that, but it doesn't work.
I mean select "Release" as the current build configuration. After you
compile, what directory does the .exe appear in? If it's a Debug directory,
then it won't run on any computer without the compiler installed. Note that
the directory name isn't what counts, it's just a good indicator under the
default project options.

The build configuration appears on the "Standard" toolbar in Visual Studio
2005.
>
--
"It is easy in the world to live after the world's opinion; it easy in
solitude to live after our own; but the great man is he who in the midst
of the crowd keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 18 '07 #4

P: n/a
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
>"Ben Voigt" <rb*@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...
>>>
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
I wrote this very simple code in .NET VC++. I compiled it on my system, and
tried to run it on my friend's computer (he doesn't have the compiler). We
both have Windows XP Professional. I have .NET framework 2.0, and he had 1.0
and it didn't work; then he installed 2.0 and it still didn't work; so he
tried with 2.1 and it didn't work, then 3.0 and nothing still worked. I have
Intel Centrino Mobile (laptop computer), and he has Intel Pentium 4 (desktop
computer). His system reported an error that it cannot execute the program
because of invalid configuration. Why doesn't it work?

Did you do a release compile? The debug compile in C++ requires debug
libraries that are only present when the compiler is installed.

Do you mean by going to Build->Compile in the menu (or pressing Ctrl+F7)? I
did that, but it doesn't work.

I mean select "Release" as the current build configuration. After you
compile, what directory does the .exe appear in? If it's a Debug directory,
then it won't run on any computer without the compiler installed. Note that
the directory name isn't what counts, it's just a good indicator under the
default project options.

The build configuration appears on the "Standard" toolbar in Visual Studio
2005.
OK, that solved the problem with the error. The program now runs, but is
terminated by Windows. Windows reports being low on Virtual Memory.

Now I know for a fact that my roommate has his Virtual Memory size set to zero.
However, what I don't understand is why the program won't run, given that he has
1.7GB of RAM free most of the time (idle Windows only use about 300MB). Why
won't Windows use physical memory, but instead insist on using virtual memory
for this program? Other programs run just fine on his computer.

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #5

P: n/a
"Sourcerer" <en****@MAKNIgmail.comwrote in message news:ep**********@ss408.t-com.hr...
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>
"Sourcerer" <en****@MAKNIgmail.comwrote in message news:eo**********@ss408.t-com.hr...
>>"Ben Voigt" <rb*@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...

"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
>I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to
>run it on my friend's computer (he doesn't have the compiler). We both have Windows XP
>Professional. I have .NET framework 2.0, and he had 1.0 and it didn't work; then he
>installed 2.0 and it still didn't work; so he tried with 2.1 and it didn't work, then
>3.0 and nothing still worked. I have Intel Centrino Mobile (laptop computer), and he
>has Intel Pentium 4 (desktop computer). His system reported an error that it cannot
>execute the program because of invalid configuration. Why doesn't it work?

Did you do a release compile? The debug compile in C++ requires debug libraries that
are only present when the compiler is installed.

Do you mean by going to Build->Compile in the menu (or pressing Ctrl+F7)? I did that,
but it doesn't work.

I mean select "Release" as the current build configuration. After you compile, what
directory does the .exe appear in? If it's a Debug directory, then it won't run on any
computer without the compiler installed. Note that the directory name isn't what counts,
it's just a good indicator under the default project options.

The build configuration appears on the "Standard" toolbar in Visual Studio 2005.

OK, that solved the problem with the error. The program now runs, but is terminated by
Windows. Windows reports being low on Virtual Memory.

Now I know for a fact that my roommate has his Virtual Memory size set to zero. However,
what I don't understand is why the program won't run, given that he has 1.7GB of RAM free
most of the time (idle Windows only use about 300MB). Why won't Windows use physical
memory, but instead insist on using virtual memory for this program? Other programs run
just fine on his computer.

--
"It is easy in the world to live after the world's opinion; it easy in solitude to live
after our own; but the great man is he who in the midst of the crowd keeps with perfect
sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/


while (1) {
a = (int *) malloc(100000 * sizeof(int));
}

Not surprising, this is an endless loop, you keep allocating memory until all your VAS is
exhausted. What did you expect from this code?

Willy.

Jan 24 '07 #6

P: n/a
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uF**************@TK2MSFTNGP02.phx.gbl...
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:ep**********@ss408.t-com.hr...
>"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>>
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl...
>
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
>>I wrote this very simple code in .NET VC++. I compiled it on my system,
>>and tried to run it on my friend's computer (he doesn't have the
>>compiler). We both have Windows XP Professional. I have .NET framework
>>2.0, and he had 1.0 and it didn't work; then he installed 2.0 and it still
>>didn't work; so he tried with 2.1 and it didn't work, then 3.0 and nothing
>>still worked. I have Intel Centrino Mobile (laptop computer), and he has
>>Intel Pentium 4 (desktop computer). His system reported an error that it
>>cannot execute the program because of invalid configuration. Why doesn't
>>it work?
>
Did you do a release compile? The debug compile in C++ requires debug
libraries that are only present when the compiler is installed.

Do you mean by going to Build->Compile in the menu (or pressing Ctrl+F7)? I
did that, but it doesn't work.

I mean select "Release" as the current build configuration. After you
compile, what directory does the .exe appear in? If it's a Debug directory,
then it won't run on any computer without the compiler installed. Note that
the directory name isn't what counts, it's just a good indicator under the
default project options.

The build configuration appears on the "Standard" toolbar in Visual Studio
2005.

OK, that solved the problem with the error. The program now runs, but is
terminated by Windows. Windows reports being low on Virtual Memory.

Now I know for a fact that my roommate has his Virtual Memory size set to
zero. However, what I don't understand is why the program won't run, given
that he has 1.7GB of RAM free most of the time (idle Windows only use about
300MB). Why won't Windows use physical memory, but instead insist on using
virtual memory for this program? Other programs run just fine on his
computer.

--
"It is easy in the world to live after the world's opinion; it easy in
solitude to live after our own; but the great man is he who in the midst of
the crowd keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/


while (1) {
a = (int *) malloc(100000 * sizeof(int));
}

Not surprising, this is an endless loop, you keep allocating memory until all
your VAS is exhausted. What did you expect from this code?
No, you misunderstood. It's supposed to be an endless loop. However, the program
doesn't even begin execution. We were monitoring the performance in Task
Manager, to see how the memory gets allocated. On my system, the memory is
properly allocated until it is all gone, and then I terminate the execution by
force. On his system, nothing gets allocated. The performance meters don't show
any memory being allocated at all.

My question is, what does this have to do with Virtual Memory? I want to occupy
physical memory, not virtual.

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #7

P: n/a
In article <ep**********@ss408.t-com.hr>,
Sourcerer <en****@MAKNIgmail.comwrote:
>My question is, what does this have to do with Virtual Memory? I
want to occupy physical memory, not virtual.
So does everybody. But, when every app wants a lot of physical
memory, then something's gotta give. Virtual memory is the way of
fulfilling the promises made to each app, allowing them to share the
physical memory. Consider virtual memory the security for a loan
you're getting.

Nathan Mates

--
<*Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
Jan 24 '07 #8

P: n/a
"Nathan Mates" <na****@visi.comwrote in message
news:12*************@corp.supernews.com...
In article <ep**********@ss408.t-com.hr>,
Sourcerer <en****@MAKNIgmail.comwrote:
>>My question is, what does this have to do with Virtual Memory? I
want to occupy physical memory, not virtual.

So does everybody. But, when every app wants a lot of physical
memory, then something's gotta give. Virtual memory is the way of
fulfilling the promises made to each app, allowing them to share the
physical memory. Consider virtual memory the security for a loan
you're getting.
Something has to go wrong eventually, yes, but why is the program terminated
immediately?
Why doesn't the system allocate physical memory when it is available, and only
when it's running out go tamper with virtual memory?

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #9

P: n/a

"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:ep*********@ss408.t-com.hr...
"Nathan Mates" <na****@visi.comwrote in message
news:12*************@corp.supernews.com...
>In article <ep**********@ss408.t-com.hr>,
Sourcerer <en****@MAKNIgmail.comwrote:
>>>My question is, what does this have to do with Virtual Memory? I
want to occupy physical memory, not virtual.

So does everybody. But, when every app wants a lot of physical
memory, then something's gotta give. Virtual memory is the way of
fulfilling the promises made to each app, allowing them to share the
physical memory. Consider virtual memory the security for a loan
you're getting.

Something has to go wrong eventually, yes, but why is the program
terminated immediately?
Why doesn't the system allocate physical memory when it is available, and
only when it's running out go tamper with virtual memory?
Only kernel-mode code can use physical memory, all user code uses virtual
memory which can be mapped into physical memory or into the swapfile (also
called pagefile). You can't disable virtual memory, the VMM is essential to
any modern OS because it does stack allocation, process isolation, and a
host of other stuff that's not related to the swapfile. You can only
disable the swapfile. Some things can still be purged temporarily from
physical ram even without a swapfile, specifically read-only segments which
are mainly code (because the system can always get them back from disk).
That's one reason you can't delete a program that's running.

In fact, with 1.7GB of physical ram, you are as likely to run out of virtual
memory space (2 GB limit, which can be fragmented leaving holes, and even
though you haven't much fragmentation in your allocation pattern, the DLL
load addresses cause some holes in your address space) as physical.

Why the program terminates immediately I can't quite say. How do you know
it isn't running? On a fast processor it could finish before task manager
ever notices it. Perhaps if you write to a file at the beginning of the
program, you can find out if it ever starts up. You could also log after
each allocation to find out how many times the loop runs. Make sure you
flush the file after each write, otherwise the runtime library will cache
your messages in memory, and they'll be lost when the error occurs.
>
--
"It is easy in the world to live after the world's opinion; it easy in
solitude to live after our own; but the great man is he who in the midst
of the crowd keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #10

P: n/a
"Sourcerer" <en****@MAKNIgmail.comwrote in message news:ep**********@ss408.t-com.hr...
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uF**************@TK2MSFTNGP02.phx.gbl...
>"Sourcerer" <en****@MAKNIgmail.comwrote in message news:ep**********@ss408.t-com.hr...
>>"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .

"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:eo**********@ss408.t-com.hr...
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:Ok**************@TK2MSFTNGP03.phx.gbl.. .
>>
>"Sourcerer" <en****@MAKNIgmail.comwrote in message
>news:eo**********@ss408.t-com.hr...
>>>I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to
>>>run it on my friend's computer (he doesn't have the compiler). We both have Windows
>>>XP Professional. I have .NET framework 2.0, and he had 1.0 and it didn't work; then
>>>he installed 2.0 and it still didn't work; so he tried with 2.1 and it didn't work,
>>>then 3.0 and nothing still worked. I have Intel Centrino Mobile (laptop computer),
>>>and he has Intel Pentium 4 (desktop computer). His system reported an error that it
>>>cannot execute the program because of invalid configuration. Why doesn't it work?
>>
>Did you do a release compile? The debug compile in C++ requires debug libraries that
>are only present when the compiler is installed.
>
Do you mean by going to Build->Compile in the menu (or pressing Ctrl+F7)? I did that,
but it doesn't work.

I mean select "Release" as the current build configuration. After you compile, what
directory does the .exe appear in? If it's a Debug directory, then it won't run on any
computer without the compiler installed. Note that the directory name isn't what
counts, it's just a good indicator under the default project options.

The build configuration appears on the "Standard" toolbar in Visual Studio 2005.

OK, that solved the problem with the error. The program now runs, but is terminated by
Windows. Windows reports being low on Virtual Memory.

Now I know for a fact that my roommate has his Virtual Memory size set to zero. However,
what I don't understand is why the program won't run, given that he has 1.7GB of RAM
free most of the time (idle Windows only use about 300MB). Why won't Windows use
physical memory, but instead insist on using virtual memory for this program? Other
programs run just fine on his computer.

--
"It is easy in the world to live after the world's opinion; it easy in solitude to live
after our own; but the great man is he who in the midst of the crowd keeps with perfect
sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/


while (1) {
a = (int *) malloc(100000 * sizeof(int));
}

Not surprising, this is an endless loop, you keep allocating memory until all your VAS is
exhausted. What did you expect from this code?

No, you misunderstood. It's supposed to be an endless loop. However, the program doesn't
even begin execution. We were monitoring the performance in Task Manager, to see how the
memory gets allocated. On my system, the memory is properly allocated until it is all
gone, and then I terminate the execution by force. On his system, nothing gets allocated.
The performance meters don't show any memory being allocated at all.
If you run this on a system that is able to allocate all available VAS, before taskman is
showing the memory counter's value, you won't see anything *unusual*, more your program will
probably prevent Taskman from updating the UI in a timely fashion, because your program pegs
the CPU and the Memory system.
Beware that the smallest interval between the fetches is 1 second, fast systems are able to
allocate much more RAM than available on most systems within one second.
To illustrate what I'm saying, add a Sleep(10) call between each malloc and watch Taskman.
My question is, what does this have to do with Virtual Memory? I want to occupy physical
memory, not virtual.
You will occupy physical memory, but this is not under your control, neither will you
allocate physical memory only by calling malloc, you need to write to this memory before
virtual memory (reserved) turns into physical (comitted).

Willy.
Jan 25 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.