Announcement

Collapse
No announcement yet.

Why can I not alloc more than 240 Bytes ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why can I not alloc more than 240 Bytes ?

    Hello,

    I'm using XPort Pro and I try to make a software to convert some data from serial port to ethernet port.

    For this project I need to allocate memory in XPort in order to create my data. I use malloc() and I don't understand why when I ask for memory allocation more than 240 Bytes, I get an error...

    Here some information I got :

    malloc(239) -> it works
    malloc(240) -> it works
    malloc(241) -> it doesn't work...

    An error appears :

    Code:
    # Allocation of length 1229529155 from process 60 (Test) failed
    DMA per-cpu:
    CPU    0: hi:    0, btch:   1 usd:   0
    Active_anon:0 active_file:56 inactive_anon:0
     inactive_file:280 unevictable:0 dirty:0 writeback:0 unstable:0
     free:273 slab:410 mapped:0 pagetables:0 bounce:0
    DMA free:1092kB min:360kB low:448kB high:540kB active_anon:0kB inactive_anon:0kB active_file:224kB inactive_file:1120kB unevictable:0kB present:8128kB pages_scanned:0 all_unreclaimable? no
    lowmem_reserve[]: 0 0 0
    DMA: 1*4kB 0*8kB 2*16kB 1*32kB 0*64kB 0*128kB 0*256kB 0*512kB 1*1024kB 0*2048kB 0*4096kB = 1092kB
    339 total pagecache pages
    Someone could help me ?

  • #2
    Can I modify 'SLAB allocator' parameter to be allowed of using bigger allocation ?
    Is this solution is safe ?

    Comment


    • #3
      Hello,

      I think that the malloc error occurred because you allocated 1229529155 bytes. Please check your code.
      In the system of NOMMU, malloc() allocates memory using alloc_pages() of kernel. So, adjustment of SLAB will be ineffective.

      Code:
      DMA: 1*4kB 0*8kB 2*16kB 1*32kB 0*64kB 0*128kB 0*256kB 0*512kB 1*1024kB 0*2048kB 0*4096kB = 1092kB
      339 total pagecache pages
      In this case, you could allocate about 1024KB at the maximum.

      Comment


      • #4
        Hello tfujii,

        This errors appeared when I tried of allocating 241 bytes. I had only 1 instruction in my code which was malloc(240) or malloc(241) for debug...

        When this instruction was executed, I had this error...
        It doesn't matter, I've chosen of working with static memory. I don't know what happened, maybe some kernel options were wrong...

        Thanks

        Comment

        Working...
        X