Hi all..

I have an interesting problem..

When I compare the Memory allocation routine of MASM ( Alloc and Free, Memfill ) against VC++ alloc, memset and free..
VC's routine far faster that MASM routine.. Why is it so ??

Is it because of badly written MASM library for ( Alloc, Free, Memfill )..

How i have tested :-

I have written a small procedure in MASM which is called from C routine and accepts no. of bytes to allocate ( Alloc ) memfill that allocated memory and free the block..

With same logic I have written a C procedure which does the same thing using malloc, memset and free.

I call the procedure from a Loop which i am running for large value.. and C routine simply outperform the assemble routine..

Any ideas..

Posted on 2003-02-09 02:35:56 by processingspeed
Well the obvious question here is what routines are you using?

If the one in the Masm Lib are slower than VC ones then use one of the others options, GlobalAlloc, HeapAlloc or even VirtualAlloc given the right circumstances.

In general though if you need to allocate memory quickly it may be best to come up with your own memory management.
Posted on 2003-02-09 05:29:48 by Eóin
What you will probably find is that the C prog has a larger buffer that it allocates from so reallocating small blocks should be faster that way.

Try using the OLE string functions for allocating memory if you want to do it that way as it is well suited for small multiple blocks.

There are two macros in MASM32 that handle them with no problems, stralloc & strfree.

E?in's suggestion is the direction you would take if you have to allocate memory in that manner, handle a large block yourself and read and write to controlled sections of it.


Posted on 2003-02-09 06:34:04 by hutch--