I tested it also with the engine sdk in Visual Studio Community 2015. Maybe this is helpfull, because it's possible to look inside the structs.

Code:
#define WIN32_LEAN_AND_MEAN		
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include "var.h"
#include "adll.h"

ENGINE_VARS *ev;
COLOR COLOR_RED = { _VAR(255), _VAR(0), _VAR(0) };
COLOR COLOR_WHITE = { _VAR(255), _VAR(255), _VAR(255) };

#define MAX_BMAPS 196 // start with the default nexus/ "run current script"
BMAP* test_bmps[MAX_BMAPS];
int num_bmaps = 0;

int APIENTRY WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR     lpCmdLine,
	int       nCmdShow)
{
	ev = engine_open(NULL);

	int i;
	v(fps_max) = 60;
	v(video_mode) = 6;
	engine_frame();
	static BMAP* source_bmp = bmap_create("test8MB3.tga");
	
	while (engine_frame()) {

		if (num_bmaps < MAX_BMAPS)
		{
			if (1) // < ---------- here
			{
				test_bmps[num_bmaps] = bmap_createblack(_VAR(2048), _VAR(1024), _VAR(32));
				bmap_blit(test_bmps[num_bmaps], source_bmp, NULL, NULL);
			}
			else test_bmps[num_bmaps] = bmap_create((char *)"test8MB3.tga");
			draw_quad(test_bmps[num_bmaps], vector(_VAR(10), _VAR(10), _VAR(10)), NULL, NULL, NULL, NULL, _VAR(100), _VAR(0));
			//cprintf4("n%d) w %d, h %d, b %d",(int)(num_bmaps+1),(int)test_bmps[num_bmaps]->finalwidth,(int)test_bmps[num_bmaps]->finalheight,(int)test_bmps[num_bmaps]->finalbytespp);
			num_bmaps++;
		}
		draw_text(_CHR(str_printf(NULL, "sys_memory: %.1f", (double)v(sys_memory))), _VAR(20), _VAR(20), &COLOR_RED);
		draw_text(_CHR(str_printf(NULL, "d3d_texbmaps: %.1f", (double)v(d3d_texbmaps))), _VAR(20), _VAR(40), &COLOR_RED);
		draw_text(_CHR(str_printf(NULL, "nexus: %.1f/ %d", (double)v(nexus), (int)v(max_nexus))), _VAR(20), _VAR(60), &COLOR_WHITE);
		draw_text(_CHR(str_printf(NULL, "d3d_texfree: %.1f", (double)v(d3d_texfree))), _VAR(20), _VAR(80), &COLOR_WHITE);
		draw_text(_CHR(str_printf(NULL, "num_bmaps: %d", (int)num_bmaps)), _VAR(20), _VAR(120), &COLOR_WHITE);
	}
	engine_close();
	return 0;
}



For me it has the exact same result like running the script with SED.

I don't know if this is relevant (I really doubt it has something to do with the memory problems), but when I use if(1), the u1,v1- and u2,v2-coordinates of the bitmaps are not zero but slightly off:

Code:
u1	0.000244140625	float
v1	0.000488281250	float
u2	0.999755859	float
v2	0.999511719	float



This is even true for the source_bmp which is declared before the if branch. I have no idea what is going on here.

Here is something more interesting. When I'm using if(0) and I look inside the bmap members I can see that the pixel member is filled:

Code:
pixels	0x0bd3d020 "T^nÿWaqÿYctÿZduÿZeuÿ\gwÿ]hxÿ]hxÿ\fvÿYduÿXbsÿYctÿYctÿXbsÿWbrÿWbrÿXbrÿWaqÿV`pÿU_nÿT^mÿT^mÿS]kÿR\jÿS^kÿT^lÿS]kÿQ[iÿPYgÿOXfÿOXfÿPYgÿOYfÿNWeÿOXeÿOXeÿOXfÿQZhÿQ[iÿQ[iÿQZhÿOXeÿNWdÿNWdÿNWdÿNWdÿOXfÿOXfÿPYgÿPYgÿ...	84 'T' unsigned char *



But when I'm changing the branch to if(1) the pixel member of the bitmap created by bmap_createblack can't be read:
Code:
pixels	0x00000000 <NULL> <Unable to read memory>	unsigned char *


This is also true, after bmap_blit is used.

Could it be, that the pixel member of a bitmap takes up 8 MB of memory? If bmap_create is used, the pixel member is filled. But when bmap_createblack or bmap_blit is used, the pixel member is NULL. Maybe this is the cause the first function can only create half as many bitmaps until the memory is full. (1.6 GB equals 200 * 8 MB or 100 * 16 MB)