linux memory management in portable ubuntu?

Net

Golden Member
Aug 30, 2003
1,592
2
81
i put this in programming since it would make more sense to the programmer then the non-programming linux user. If it is better suited for operating system please move.

memory is handled differently in linux vs windows. for instance how memory is allocated in a struct.

if I program under portable ubuntu running in windows will it be the same as linux? all the querks, memory management, etc...

my next class is all under linux. a part of the class they will take our code, put bugs in it and as a test we debug it in their lab which runs linux.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Ubuntu is Linux. Different versions of gcc may allocate things differently but I doubt you'll be getting deep enough for that to matter.
 

Net

Golden Member
Aug 30, 2003
1,592
2
81
Ubuntu is Linux. Different versions of gcc may allocate things differently but I doubt you'll be getting deep enough for that to matter.

i know. i'm concerned that since its running ontop of windows that it might be more like a virtual machine. which might cause problems?
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: net
Ubuntu is Linux. Different versions of gcc may allocate things differently but I doubt you'll be getting deep enough for that to matter.

i know. i'm concerned that since its running ontop of windows that it might be more like a virtual machine. which might cause problems?

It is a virtual machine.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
i know. i'm concerned that since its running ontop of windows that it might be more like a virtual machine. which might cause problems?

It is a virtual machine, nothing knows it's in the VM and minus the emulated hardware and such nothing is different.
 

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
you can use gcc on windows,

how struct is stored in memory it depends of programmer, whether he decides to put it on heap or stack, for example.
 

Gamingphreek

Lifer
Mar 31, 2003
11,679
0
81
Originally posted by: postmortemIA
you can use gcc on windows,

how struct is stored in memory it depends of programmer, whether he decides to put it on heap or stack, for example.

Exactly - I'm not sure what you mean by memory is handled different.

While the request might be scheduled and processed different but the language and the allocator calls remain the same.

For instance:
Calling the 'new' allocator will request space on the heap. Instantiating statically will request space on the stack. (Of course there is a bit more than those 2 stipulations as to where it goes).

-Kevin
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Exactly - I'm not sure what you mean by memory is handled different.

I figured he meant the actual position in memory which can change with different compiler versions, options, etc.
 

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
Originally posted by: Nothinman
Exactly - I'm not sure what you mean by memory is handled different.

I figured he meant the actual position in memory which can change with different compiler versions, options, etc.

I doubt any compiler will allocate more memory space than needed for a struct, so even if there are differences, they are irrelevant. The only relevant difference would be stack vs hep vs managed environment (Java, .NET)
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I doubt any compiler will allocate more memory space than needed for a struct, so even if there are differences, they are irrelevant. The only relevant difference would be stack vs hep vs managed environment (Java, .NET)

I mainly meant order, i.e. does the int variable i come before char c in memory or vice versa. And different versions of compilers optimize differently so things can get shuffled around. And as net says with structs there's alignment to think about too.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Originally posted by: Nothinman
I doubt any compiler will allocate more memory space than needed for a struct, so even if there are differences, they are irrelevant. The only relevant difference would be stack vs hep vs managed environment (Java, .NET)

I mainly meant order, i.e. does the int variable i come before char c in memory or vice versa. And different versions of compilers optimize differently so things can get shuffled around. And as net says with structs there's alignment to think about too.

It depends on the target machine too. It may be wise to not fully pack a struct (or maybe explicitly pad the struct) for performance reasons.

For the OP:
Originally posted by: net
if I program under portable ubuntu running in windows will it be the same as linux? all the querks, memory management, etc...
If your program is correct, it will run the same. Correct programs, especially 'assignment-level programs' are almost always independent of the virtual address structure. If your code breaks when the memory manager changes, its probably indicative of a bug in your code.