memory leakage when taskSpawn and taskDelete - VxWorks

This is a discussion on memory leakage when taskSpawn and taskDelete - VxWorks ; My vxworks version is 5.5.1 But in my system, After taskSpawn and taskDelete, free memory decrease 88bytes and allocation block plus 1 according to the memShow. what is wrong ?? please give me a your suggestion. --...

+ Reply to Thread
Results 1 to 10 of 10

Thread: memory leakage when taskSpawn and taskDelete

  1. memory leakage when taskSpawn and taskDelete


    My vxworks version is 5.5.1

    But in my system, After taskSpawn and taskDelete, free memory decrease

    88bytes and allocation block plus 1 according to the memShow.

    what is wrong ??

    please give me a your suggestion.

    --


  2. Re: memory leakage when taskSpawn and taskDelete

    Please paste your code snippets...


    cykri wrote:
    > My vxworks version is 5.5.1
    >
    > But in my system, After taskSpawn and taskDelete, free memory decrease
    >
    > 88bytes and allocation block plus 1 according to the memShow.
    >
    > what is wrong ??
    >
    > please give me a your suggestion.
    >
    > --



  3. Re: memory leakage when taskSpawn and taskDelete


    > Please paste your code snippets...
    >
    >
    > cykri wrote:
    > > My vxworks version is 5.5.1
    > >
    > > But in my system, After taskSpawn and taskDelete, free memory
    > > decrease
    > >
    > > 88bytes and allocation block plus 1 according to the memShow.
    > >
    > > what is wrong ??
    > >
    > > please give me a your suggestion.
    > >
    > > --


    In my code,

    int temp_task;

    void phs_task()

    {
    printf("\n\nkkkk-1\n\n");

    if (taskDelete(taskIdSelf()) == ERROR)
    {
    printf("kkkk-2\n");
    }
    }

    void phs_task_start()
    {
    temp_task = taskSpawn("phs",
    64,
    ,
    20000,
    (FUNCPTR )phs_task,
    , 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

    Before phs_task_start command in target shell,
    -> memShow
    status bytes blocks avg block max block
    ------ ---------- --------- ---------- ----------
    current
    free 9464848 43 220112 9123072
    alloc 107452392 1018 105552 -
    cumulative
    alloc 107962896 1277 84544 -
    value = 0 = 0x0

    After phs_task_start command
    -> memShow
    status bytes blocks avg block max block
    ------ ---------- --------- ---------- ----------
    current
    free 9464760 44 215108 9123072
    alloc 107452480 1019 105448 -
    cumulative
    alloc 107983552 1282 84230 -
    value = 0 = 0x0

    As you see above,
    free memory decrease 88 bytes, alloc blocks plus 1. -.-

    --


  4. Re: memory leakage when taskSpawn and taskDelete

    Hi!

    It's the target shell taht consmues the memory.

    BT

    "cykri" wrote in message
    news:140$1433521$5194706$1151374215@sysadminforum. com...
    >
    >> Please paste your code snippets...
    >>
    >>
    >> cykri wrote:
    >> > My vxworks version is 5.5.1
    >> >
    >> > But in my system, After taskSpawn and taskDelete, free memory
    >> > decrease
    >> >
    >> > 88bytes and allocation block plus 1 according to the memShow.
    >> >
    >> > what is wrong ??
    >> >
    >> > please give me a your suggestion.
    >> >
    >> > --

    >
    > In my code,
    >
    > int temp_task;
    >
    > void phs_task()
    >
    > {
    > printf("\n\nkkkk-1\n\n");
    >
    > if (taskDelete(taskIdSelf()) == ERROR)
    > {
    > printf("kkkk-2\n");
    > }
    > }
    >
    > void phs_task_start()
    > {
    > temp_task = taskSpawn("phs",
    > 64,
    > ,
    > 20000,
    > (FUNCPTR )phs_task,
    > , 0, 0, 0, 0, 0, 0, 0, 0, 0);
    > }
    >
    > Before phs_task_start command in target shell,
    > -> memShow
    > status bytes blocks avg block max block
    > ------ ---------- --------- ---------- ----------
    > current
    > free 9464848 43 220112 9123072
    > alloc 107452392 1018 105552 -
    > cumulative
    > alloc 107962896 1277 84544 -
    > value = 0 = 0x0
    >
    > After phs_task_start command
    > -> memShow
    > status bytes blocks avg block max block
    > ------ ---------- --------- ---------- ----------
    > current
    > free 9464760 44 215108 9123072
    > alloc 107452480 1019 105448 -
    > cumulative
    > alloc 107983552 1282 84230 -
    > value = 0 = 0x0
    >
    > As you see above,
    > free memory decrease 88 bytes, alloc blocks plus 1. -.-
    >
    > --
    >




  5. Re: memory leakage when taskSpawn and taskDelete


    > Hi!
    >
    > It's the target shell taht consmues the memory.
    >
    > BT
    >
    > "cykri" wrote in message
    > news:140$1433521$5194706$1151374215@sysadminforum. com...
    > >
    > >> Please paste your code snippets...
    > >>
    > >>
    > >> cykri wrote:
    > >> > My vxworks version is 5.5.1
    > >> >
    > >> > But in my system, After taskSpawn and taskDelete, free memory
    > >> > decrease
    > >> >
    > >> > 88bytes and allocation block plus 1 according to the memShow.
    > >> >
    > >> > what is wrong ??
    > >> >
    > >> > please give me a your suggestion.
    > >> >
    > >> > --

    > >
    > > In my code,
    > >
    > > int temp_task;
    > >
    > > void phs_task()
    > >
    > > {
    > > printf("\n\nkkkk-1\n\n");
    > >
    > > if (taskDelete(taskIdSelf()) == ERROR)
    > > {
    > > printf("kkkk-2\n");
    > > }
    > > }
    > >
    > > void phs_task_start()
    > > {
    > > temp_task = taskSpawn("phs",
    > > 64,
    > > ,
    > > 20000,
    > > (FUNCPTR )phs_task,
    > > , 0, 0, 0, 0, 0, 0, 0, 0, 0);
    > > }
    > >
    > > Before phs_task_start command in target shell,
    > > -> memShow
    > > status bytes blocks avg block max block
    > > ------ ---------- --------- ---------- ----------
    > > current
    > > free 9464848 43 220112 9123072
    > > alloc 107452392 1018 105552 -
    > > cumulative
    > > alloc 107962896 1277 84544 -
    > > value = 0 = 0x0
    > >
    > > After phs_task_start command
    > > -> memShow
    > > status bytes blocks avg block max block
    > > ------ ---------- --------- ---------- ----------
    > > current
    > > free 9464760 44 215108 9123072
    > > alloc 107452480 1019 105448 -
    > > cumulative
    > > alloc 107983552 1282 84230 -
    > > value = 0 = 0x0
    > >
    > > As you see above,
    > > free memory decrease 88 bytes, alloc blocks plus 1. -.-
    > >
    > > --
    > >


    In vxworks version 5.4, there is no leakage as if same process repeates.

    Does memShow consume the memory? i don't think so.

    Does taskspawn in target shell command consume the memory?

    who consume the memory?

    Thanks you for your reply.

    --


  6. Re: memory leakage when taskSpawn and taskDelete

    Hi,

    Have you tried to run your code without the explicit call to taskDelete
    in it? Also, when you run it, does the taskDelete call fail or succeed?
    Even without the taskDelete call, when your phs_task() function has
    finished, the task should clean itself up anyway.

    Ben.


  7. Re: memory leakage when taskSpawn and taskDelete


    VxWorks does implement automatic garbage collection which will
    reclaim the memory space assigned to phs_task(). This is done in
    regular erase cycles.The memory becomes reusable only after an erase
    cycle completes. It starts when the minimum size of the memory that can
    be recovered is greater that or equal to 64KB. So this is why u cant
    see ur 88bytes of memory even when the task deletes itself.

    U try freeing more that 64KB of data from the memory, probably the
    garbage collector will recover it and u will be able to see it in
    memShow.

    Please do revert back to me with ur results.
    cykri wrote:
    > > Please paste your code snippets...
    > >
    > >
    > > cykri wrote:
    > > > My vxworks version is 5.5.1
    > > >
    > > > But in my system, After taskSpawn and taskDelete, free memory
    > > > decrease
    > > >
    > > > 88bytes and allocation block plus 1 according to the memShow.
    > > >
    > > > what is wrong ??
    > > >
    > > > please give me a your suggestion.
    > > >
    > > > --

    >
    > In my code,
    >
    > int temp_task;
    >
    > void phs_task()
    >
    > {
    > printf("\n\nkkkk-1\n\n");
    >
    > if (taskDelete(taskIdSelf()) == ERROR)
    > {
    > printf("kkkk-2\n");
    > }
    > }
    >
    > void phs_task_start()
    > {
    > temp_task = taskSpawn("phs",
    > 64,
    > ,
    > 20000,
    > (FUNCPTR )phs_task,
    > , 0, 0, 0, 0, 0, 0, 0, 0, 0);
    > }
    >
    > Before phs_task_start command in target shell,
    > -> memShow
    > status bytes blocks avg block max block
    > ------ ---------- --------- ---------- ----------
    > current
    > free 9464848 43 220112 9123072
    > alloc 107452392 1018 105552 -
    > cumulative
    > alloc 107962896 1277 84544 -
    > value = 0 = 0x0
    >
    > After phs_task_start command
    > -> memShow
    > status bytes blocks avg block max block
    > ------ ---------- --------- ---------- ----------
    > current
    > free 9464760 44 215108 9123072
    > alloc 107452480 1019 105448 -
    > cumulative
    > alloc 107983552 1282 84230 -
    > value = 0 = 0x0
    >
    > As you see above,
    > free memory decrease 88 bytes, alloc blocks plus 1. -.-
    >
    > --



  8. Re: memory leakage when taskSpawn and taskDelete


    > Hi,
    >
    > Have you tried to run your code without the explicit call to
    > taskDelete
    > in it? Also, when you run it, does the taskDelete call fail or
    > succeed?
    > Even without the taskDelete call, when your phs_task() function has
    > finished, the task should clean itself up anyway.
    >
    > Ben.


    Even if there is no the explicit call to taskdelete, leak exist. >.<

    For more informatin.

    When vxworks spawns a task, it performs two mallocs. stack and 80bytes.

    When vxworks deletes a task, it performs one free, stack.

    80 bytes free is not performed by O.S.

    --


  9. Re: memory leakage when taskSpawn and taskDelete

    Hi Rahul,
    I am not sure what do you mean "reclaim the memory space assigned to
    phs_task()."?

    Moreover, how about the 88 bytes, are they really FREEd? Since they are
    known to os, could be used as free memory for re-allocation?

    What do you mean the "rugular erase cycyles"?

    Thanks!


    Rahul kashyap 写道:

    > VxWorks does implement automatic garbage collection which will
    > reclaim the memory space assigned to phs_task(). This is done in
    > regular erase cycles.The memory becomes reusable only after an erase
    > cycle completes. It starts when the minimum size of the memory that can
    > be recovered is greater that or equal to 64KB. So this is why u cant
    > see ur 88bytes of memory even when the task deletes itself.
    >
    > U try freeing more that 64KB of data from the memory, probably the
    > garbage collector will recover it and u will be able to see it in
    > memShow.
    >
    > Please do revert back to me with ur results.
    > cykri wrote:
    > > > Please paste your code snippets...
    > > >
    > > >
    > > > cykri wrote:
    > > > > My vxworks version is 5.5.1
    > > > >
    > > > > But in my system, After taskSpawn and taskDelete, free memory
    > > > > decrease
    > > > >
    > > > > 88bytes and allocation block plus 1 according to the memShow.
    > > > >
    > > > > what is wrong ??
    > > > >
    > > > > please give me a your suggestion.
    > > > >
    > > > > --

    > >
    > > In my code,
    > >
    > > int temp_task;
    > >
    > > void phs_task()
    > >
    > > {
    > > printf("\n\nkkkk-1\n\n");
    > >
    > > if (taskDelete(taskIdSelf()) == ERROR)
    > > {
    > > printf("kkkk-2\n");
    > > }
    > > }
    > >
    > > void phs_task_start()
    > > {
    > > temp_task = taskSpawn("phs",
    > > 64,
    > > ,
    > > 20000,
    > > (FUNCPTR )phs_task,
    > > , 0, 0, 0, 0, 0, 0, 0, 0, 0);
    > > }
    > >
    > > Before phs_task_start command in target shell,
    > > -> memShow
    > > status bytes blocks avg block max block
    > > ------ ---------- --------- ---------- ----------
    > > current
    > > free 9464848 43 220112 9123072
    > > alloc 107452392 1018 105552 -
    > > cumulative
    > > alloc 107962896 1277 84544 -
    > > value = 0 = 0x0
    > >
    > > After phs_task_start command
    > > -> memShow
    > > status bytes blocks avg block max block
    > > ------ ---------- --------- ---------- ----------
    > > current
    > > free 9464760 44 215108 9123072
    > > alloc 107452480 1019 105448 -
    > > cumulative
    > > alloc 107983552 1282 84230 -
    > > value = 0 = 0x0
    > >
    > > As you see above,
    > > free memory decrease 88 bytes, alloc blocks plus 1. -.-
    > >
    > > --



  10. Re: memory leakage when taskSpawn and taskDelete


    > Even if there is no the explicit call to taskdelete, leak exist. >.<
    >
    > For more informatin.
    >
    > When vxworks spawns a task, it performs two mallocs. stack and
    > 80bytes.
    >
    > When vxworks deletes a task, it performs one free, stack.
    >
    > 80 bytes free is not performed by O.S.


    i got it!!

    The difference T201 and T221 of TCB Structure is pSelectContext
    structure.

    T221 taskDelete does not free pSelectContext structure.

    So we add taskDeleteHookAdd free(tcb->pSelectContext), there is no leak.

    Have a nice day!

    --


+ Reply to Thread