0

I am finding it very hard to get the details of how memory management is done in BADA OS.

Does anyone have any info about it or do all smart-phones have similar memory management concepts?

Anirudha
  • 32,393
  • 7
  • 68
  • 89

2 Answers2

1

Programming on bada you mainly have to deal with heap-memory. In some classes of bada-API you have to use automatic memory management (Osp::Base::Collection can release memory of its elements if you want; in Osp::Ui::Container method RemoveControl() will free memory of his child ).

But in general cases you need handle memory freeing by yourself.

triclosan
  • 5,578
  • 6
  • 26
  • 50
1

Memory management in BADA follows the conventional C++ memory handling policy.

An app is always responsible for deleting memory it allocates (every call to new must have a symmetrical call to delete)

Memory in BADA at runtime is divided between:

Static memory :Assigned by the compiler and is part of the application binary at runtime.

Stack memory:Allocated and freed at runtime by the OS as function activation frames for the running program are created and released

Heap memory:Allocated and freed dynamically as requested by a program.

Object Ownership Responsibilities

A further small, but important, complication relating to memory allocation and object construction is that sometimes framework methods require the framework to allocate and return a new object to the calling app.

However, once the object is returned by the framework, and the object is passed into the ownership of the caller, the framework no longer knows when the object is finished with.

In this case, the simple rule that allocating and freeing memory should always be done symmetrically no longer holds.

The problem for the app programmer is, then, to know whether or not the app, or the framework, should be responsible for cleaning up a given object.

This problem is solved almost trivially in BADA by a simple naming convention, and the associated rule

Convention

Trailing ā€˜N’ in a method name, for example: Sometype() to SomethingN()

Rule

The caller is always responsible for deleting objects returned by a framework method named with a trailing ā€˜N

Anirudha
  • 32,393
  • 7
  • 68
  • 89
  • Some exceptions to that. When you allocate controls with `new` and add them to a container (i. e. a Panel), you relinquish ownership. The framework frees them when the UI is torn down. Also, IList::RemoveAll(true) frees all the contained objects. – Seva Alekseyev Jun 13 '12 at 21:13