[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] memory allocation failure when execute 5MB application on microblaze uclinux on Spartan3E revD starter kit with petalinux 0.3



Hi,

If you genuinely need more than 4mbyte of *contiguous* memory (ie a single large piece with no gaps) then you will be in trouble.  I'd reconsider what your app is trying to do, and refactor the code.  Or, enable the MMU and reconfigure the kernel accordingly.

However, if you are allocating e.g. a large multidimensional array, you can do it with many smaller allocations, one for each for, e.g.:

#define ROWS 3000
#define COLS 3000
u8 **my_array;
int i;

my_array=(u8 **)malloc(ROWS*sizeof(u8*);
for(i=0;i<ROWS;i++) {
  my_array[i]=(u8 *)malloc(COLS*sizeof(u8));
}

(error checking left as exercise for the reader).

you can then access my_array using standard array notation - my_array[row][col]

This is about a 9mbyte array, but no single alloc is greater than 3mbyte.  It may still fail if there are insufficient largge blocks of memory available.

Or, you can always cheat.  Use the MSS parameter MAIN_MEMORY_SIZE_OVERRIDE and _OFFSET parameters to reserve some memory not used by the kernel, then just code a pointer in your app to the unused part of memory space.  Not pretty, but it will work.

Regards,

John

On Fri, Feb 6, 2009 at 1:17 PM, zhangxinmin <giantbull@xxxxxxxxxxx> wrote:
subscribe microblaze-uclinux

Allocation of length 4758088 from process 57 failed
DMA per-cpu:
CPU 0: Hot: hi: 18, btch: 3 usd: 5 Cold: hi: 6, btch: 1 usd: 0
Active:1189 inactive:552 dirty:0 writeback:0 unstable:0 free:12540 slab:658 mapped:0 pagetables:0
DMA free:50160kB min:1016kB low:1268kB high:1524kB active:4756kB inactive:2208kB present:65024kB pages_scanned:0 all_unreclaimable?
no
lowmem_reserve[]: 0 0
DMA: 0*4kB 0*8kB 1*16kB 1*32kB 1*64kB 1*128kB 1*256kB 1*512kB 0*1024kB 0*2048kB 12*4096kB = 50160kB
Unable to allocate RAM for process text/data, errno 12
Trace/BPT trap
any body know the reason of this issue? thanks"

i got some information,
"4MB is the largest block in system, uclinux can not allocate large memory block bigger than the max memory block, "
but if i want to allocate a 5MB memory for a dynamic array, will it be failure? but in many system, there has such requirment for big dynamic memory.
following is the meminfo of my system.
cat meminfo
MemTotal: 55428 kB
MemFree: 49864 kB
Buffers: 1028 kB
Cached: 1052 kB
SwapCached: 0 kB
Active: 784 kB
Inactive: 1284 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 0 kB
Mapped: 0 kB
Slab: 3188 kB
SReclaimable: 372 kB
SUnreclaim: 2816 kB
PageTables: 0 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 27712 kB
Committed_AS: 0 kB
VmallocTotal: 0 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB #


now i desize the application to 4MB, it can run, but whether there have ways to run bigger app on uclinux, or whether uclinux can allocate big larger dynamic memory block (12M example) for application





立刻下载 MSN 保护盾,保障 MSN 安全稳定! 现在就下载!