Ignore:
Timestamp:
Jan 19, 2010, 1:44:23 PM (11 years ago)
Author:
Sam Hocevar
Message:

Fix memory limitation method on OS X (page size was ignored) and other
systems (was using MBs instead of MiBs?).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf/lib-mem.c

    r4258 r4282  
    132132/* setrlimit(RLIMIT_AS) is ignored on OS X, we need to check memory usage
    133133 * from inside the process. Oh, and getrusage() doesn't work either. */
     134#if defined HAVE_MACH_TASK_H
     135vm_size_t mach_page_size;
     136#endif
     137
    134138static int memory_exceeded(void)
    135139{
     
    140144    if (task_info(mach_task_self(), TASK_BASIC_INFO,
    141145                  (task_info_t)&tbi, &mmtn) == KERN_SUCCESS
    142          && tbi.resident_size > _zz_memory)
     146         && (int64_t)tbi.resident_size * mach_page_size / 1048576
     147                  > (int64_t)_zz_memory)
    143148        return 1;
    144149#endif
     
    152157    LOADSYM(malloc);
    153158    LOADSYM(realloc);
     159
     160#if defined HAVE_MACH_TASK_H
     161    host_page_size(mach_host_self(), &mach_page_size);
     162#endif
    154163}
    155164
Note: See TracChangeset for help on using the changeset viewer.