mallocClassData,
mallocString,
mallocObject,
- getHeapMemory) where
+ getHeapMemory,
+ printMemoryUsage,
+ mallocStringVM,
+ mallocObjectVM) where
import Foreign
import Foreign.C
mallocClassData :: Int -> IO (Ptr a)
mallocClassData size = do
printfStr "mallocClassData: %d\n" size
- mallocBytesGC size
+ mem <- mallocBytes size
+ addRootGC mem (plusPtr mem size)
+ return mem
mallocString :: Int -> IO (Ptr a)
mallocString size = do
printfStr "mallocString: %d\n" size
mallocBytesGC size
+mallocStringVM :: Int -> IO (Ptr a)
+mallocStringVM = mallocBytes
+
foreign export ccall mallocObject :: Int -> IO CPtrdiff
mallocObject :: Int -> IO CPtrdiff
mallocObject size = do
printfStr "mallocObject: %d\n" size
return $ fromIntegral $ ptrToIntPtr ptr
+mallocObjectVM :: Int -> IO CPtrdiff
+mallocObjectVM size = do
+ ptr <- mallocBytes size
+ printfStr "mallocObject VM: %d\n" size
+ return $ fromIntegral $ ptrToIntPtr ptr
+
-- TODO: delete me
foreign export ccall demoInterfaceCall :: CUInt -> IO ()
demoInterfaceCall :: CUInt -> IO ()
return ()
getHeapMemory :: IO Int
-getHeapMemory = getHeapSize
+getHeapMemory = getHeapSizeGC
+
+foreign export ccall printMemoryUsage :: IO ()
+printMemoryUsage :: IO ()
+printMemoryUsage = getHeapMemory >>= print