Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* malloc/realloc on Compaq Tru64
@ 2002-05-29 18:38 Anton Enright
  2003-04-08 13:26 ` BHa
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Enright @ 2002-05-29 18:38 UTC (permalink / raw)


Hi Everyone,

Forgive my ignorance here, I'm still a pretty poor C programmer :)

I've got an application that I've written in C to run on multiple
platforms.
On Compaq T64 UNIX, when I reallocate memory it seems to take allocate
twice as much memory as I expect, and observe on other platforms (eg.
solaris).

The initial memory allocation with calloc is fine, and seems to work
exactly the same on all machines I've tried (64bit and 32bit).
Eventually
I need to reallocate memory so I double the size of an array with
realloc, on
solaris machines this works fine, but the realloc on T64 seems to use
twice as much memory as on other machines....

Can someone tell me what I'm doing wrong ?, I just want to make this
code consistent across platforms....

I'm sure this is some 64bit thing which I'm not doing right..

Heres a stripped example of what I'm doing

#include <stdio.h>
#include <stdlib.h>

/* Here's the basic struct I'm working with */
struct hit_struct{
                 unsigned char protein1[30];
                 unsigned char protein2[30];
                 unsigned char evalue1;
                 unsigned char evalue2;
                 };
int main(void)
        {
        /* Declare the variable anton */
        struct hit_struct *anton;
  
        /* Allocate an array of 100000 antons */
        anton=(struct hit_struct *) calloc(100000,sizeof(struct
hit_struct));
        
        /* Reallocate and double the size of the array */
        anton=(struct hit_struct *) realloc(anton,200000*sizeof(struct
hit_struct));
        }

When this code runs on different machines, it appears to use twice as
much memory as the initial allocation..

Any help appreciated!

Thanks

Anton


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: malloc/realloc on Compaq Tru64
  2002-05-29 18:38 malloc/realloc on Compaq Tru64 Anton Enright
@ 2003-04-08 13:26 ` BHa
  0 siblings, 0 replies; 2+ messages in thread
From: BHa @ 2003-04-08 13:26 UTC (permalink / raw)



realloc malfunction (or misuse - dont know yet) has been reported
by developpers of my corp - batch processes die when reaching
ulimit (132M).

looks like memory is never freed.

I'll tell when I know more...

--
Posted via http://dbforums.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-08 13:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-29 18:38 malloc/realloc on Compaq Tru64 Anton Enright
2003-04-08 13:26 ` BHa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox