02-26-2015
C does not have a "virtual machine" or garbage collection like Java does, operates with virtual memory, and has its own heap segment which never shrinks, which all make preallocation generally pointless except for some extremely specialized tasks. C programmers are usually more concerned with limiting memory than preallocating it.
For these specialized tasks you can use mmap(), mlock(), and madvise() to control how/when the kernel pages memory.
In short, what exactly are you trying to optimize here?
Last edited by Corona688; 02-26-2015 at 02:51 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I would like to know how I could allocate some more memory to a process.
Please note that I am not the root user. (1 Reply)
Discussion started by: sagar
1 Replies
2. UNIX for Advanced & Expert Users
Hello!
First of all, forgive me for bad English.
When I starts new thread (pthread_create), system allocates some memory for it (for example, for thread's stack). I wonder when does it deallocate this memory? The problem is that I have a program which sometimes creates new threads and sometimes... (3 Replies)
Discussion started by: prankster
3 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
I have a HP-UX Server with 4 gigabytes of physical RAM. When I use the 'Glance' utility to see what my memory utilization is, my memory usage shows up maxed out at 99%. I shut off all the known processes that I'm running on that box and the memory utilization is still at 78% (with Swap... (1 Reply)
Discussion started by: dehuang83
1 Replies
4. HP-UX
Hi all,
I have a HP-UX Server with 4 gigabytes of physical RAM. When I use the 'Glance' utility to see what my memory utilization is, my memory usage shows up maxed out at 99%. I shut off all the known processes that I'm running on that box and the memory utilization is still at 78% (with Swap... (3 Replies)
Discussion started by: dehuang83
3 Replies
5. Programming
Hi everyone,
I'm not new to C programming, but I'm having question regarding the memory allocation of a pointer variable which, for instance, will be declared in main(), but its memory will be allocated in subroutine.
To clearify my question, I provide a small working example:
#include... (1 Reply)
Discussion started by: MIB_Maik
1 Replies
6. Programming
Hi Experts
I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables.
First:
int x;
char a;
printf("%u %u\n', &x, a);
I got the addresses displayed... (2 Replies)
Discussion started by: unx_freak
2 Replies
7. Shell Programming and Scripting
hello all..
i'm a beginner in shell scripting. I need to know what is really happening when we are creating a variable in shell scripting? how memory is allocated for that variable? (3 Replies)
Discussion started by: aarathy
3 Replies
8. HP-UX
Hi,
I have HP-UX 11i v3 running on ia64. One of my application is 32-bit and I want to increase the memory allocation of this file upto 2GB. I am contentiously receiving an error message of Out of Memory.
Can you please explain the procedure what kernel configuration( like maxdsize or... (1 Reply)
Discussion started by: ahmadamin416
1 Replies
9. Programming
Hello,
I am new to C++ programming, so I'm still getting a feel for things. I recently wrote a simple C++ program (to be used as a ROOT Macro) to conduct a statistical analysis of a varied version of the Monty Hall problem (code below). Basically, the programs runs a few simple calculations to... (7 Replies)
Discussion started by: Tyler_92
7 Replies
10. UNIX for Dummies Questions & Answers
I am using ubuntu. I have written a program to calculate prime factors. it works perfectly fine till entered number is less than 9989 (or so ) but when one enters a number higher than that, for example 15000, it does not work. Can anyone guide me whats the problem ? although new codes are welcome,... (2 Replies)
Discussion started by: Abhishek_kumar
2 Replies
LEARN ABOUT LINUX
allocate
allocate(1) allocate(1)
NAME
allocate - device allocation
SYNOPSIS
allocate [-s] [-U uname] device
allocate [-s] [-U uname] -g dev-type
allocate [-s] [-U uname] -F device
The allocate utility manages the ownership of devices through its allocation mechanism. It ensures that each device is used by only one
qualified user at a time.
The device argument specifies the device to be manipulated. To preserve the integrity of the device's owner, the allocate operation is exe-
cuted on all the device special files associated with that device.
The argument dev-type is the device type to be operated on and can only be used with the -g option.
The default allocate operation allocates the device special files associated with device to the uid of the current process.
If the -F option is specified, the device cleaning program is executed when allocation is performed. This cleaning program is found in
/etc/security/lib. The name of this program is found in the device_allocate(4) entry for the device in the dev-exec field.
Only authorized users may allocate a device. The required authorizations are specified in device_allocate(4).
The following options are supported:
-g dev-type Allocates a non-allocated device with a device-type matching dev-type.
-s Silent. Suppresses any diagnostic output.
-F device Reallocates the device allocated to another user. This option is often used with -U to reallocate a specific device to a
specific user. Only a user with the solaris.device.revoke authorization is permitted to use this option.
-U uname Uses the user ID uname instead of the user ID of the current process when performing the allocate operation. Only a user
with the solaris.device.revoke authorization is permitted to use this option.
The following exit values are returned:
non--zero An error occurred.
/etc/security/device_allocate
/etc/security/device_maps
/etc/security/dev/*
/etc/security/lib/*
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
deallocate(1), list_devices(1), bsmconv(1M), dminfo(1M), mkdevalloc(1M), mkdevmaps(1M), device_allocate(4), device_maps(4), attributes(5)
The functionality described in this man page is available only if the Basic Security Module (BSM) has been enabled. See bsmconv(1M) for
more information.
/etc/security/dev, mkdevalloc(1M), and mkdevmaps(1M) might not be supported in a future release of the Solaris Operating Environment.
28 Mar 2005 allocate(1)