Changing default memory allocation method

View: New views
4 Messages — Rating Filter:   Alert me  

Changing default memory allocation method

by Nathan Schulte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm current working on some code that is part of a layered service provider.

Microsoft's example code uses the HeapCreate, HeapAlloc, HeapFree, HeapDestroy
API calls for memory allocation and deallocation.

I need to use a list in my code, and rather than follow their lead and use their
DDK Run-Time Library routines, I'm wondering if it's possible to use the STL
along with the Heap* API.

Any ideas?


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
MinGW-users mailing list
MinGW-users@...

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Re: Changing default memory allocation method

by JonY-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/24/2009 22:26, Nathan Schulte wrote:

> I'm current working on some code that is part of a layered service provider.
>
> Microsoft's example code uses the HeapCreate, HeapAlloc, HeapFree, HeapDestroy
> API calls for memory allocation and deallocation.
>
> I need to use a list in my code, and rather than follow their lead and use their
> DDK Run-Time Library routines, I'm wondering if it's possible to use the STL
> along with the Heap* API.
>
> Any ideas?

Hi,

you should be able to mix and match allocators without any issues
provided that the memory block is freed by the same allocator that
provided it.

For example, using HeapFree() to destroy blocks provided by malloc() is
just asking for trouble, use free() instead.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
MinGW-users mailing list
MinGW-users@...

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Re: Changing default memory allocation method

by Nathan Schulte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

JonY <jon_y@...> writes:
> For example, using HeapFree() to destroy blocks provided by malloc() is
> just asking for trouble, use free() instead.

Understood.  What I'm after, however, is to be able to make the new, new[],
delete and delete[] operators use HeapAlloc, HeapFree instead.  I found an
example online after coming up with a decent search term for google, however it
doesn't seem as though what I specifically was after is possible (Heap* takes a
HANDLE heap, I wanted to use a class member as this value, but said operators
are static operators at the class level.  Oh well, I should really make the
class a singleton anyway...).

Thanks!


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
MinGW-users mailing list
MinGW-users@...

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Re: Changing default memory allocation method

by Roger Pack :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Understood.  What I'm after, however, is to be able to make the new, new[],
> delete and delete[] operators use HeapAlloc, HeapFree instead.  I found an
> example online after coming up with a decent search term for google, however it
> doesn't seem as though what I specifically was after is possible (Heap* takes a
> HANDLE heap, I wanted to use a class member as this value, but said operators
> are static operators at the class level.  Oh well, I should really make the
> class a singleton anyway...).

I know with tcmalloc all you do is add
 -ltcmalloc
to the command line [haven't tried it in windows, but it might be similar].
-r

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
MinGW-users mailing list
MinGW-users@...

A: Yes.
> Q: Is it really?
>> A: Because the logical conversation flow is disrupted.
>>> Q: Why does MinGW object to top posting?
(abstracted from Larry Hall signature)

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users