Skip to content

Commit

Permalink
Add heap size limit
Browse files Browse the repository at this point in the history
to solve #342

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
JerryScript-DCO-1.0-Signed-off-by: SaeHie Park [email protected]
  • Loading branch information
seanshpark committed Jul 13, 2015
1 parent 0927888 commit bc0ca7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ project (Jerry CXX C ASM)

set(EXTERNAL_LIBC_INTERFACE "UNDEFINED" CACHE STRING "Path to external libc include directory")
set(EXTERNAL_LIBS_INTERFACE "UNDEFINED" CACHE STRING "Path to external libraries' include directory")
set(EXTERNAL_MEM_HEAP_SIZE_KB "256" CACHE STRING "Size of memory heap, in kilobytes")
else()
message(FATAL_ERROR "Platform '${PLATFORM}' is not supported")
endif()
Expand Down
6 changes: 6 additions & 0 deletions jerry-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ project (JerryCore CXX C ASM)
math(EXPR MEM_HEAP_AREA_SIZE_16K "16 * 1024")
set(DEFINES_JERRY_MCU_STM32F4 CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_16K})

# External
if(DEFINED EXTERNAL_MEM_HEAP_SIZE_KB)
math(EXPR MEM_HEAP_AREA_SIZE_EXTERNAL "${EXTERNAL_MEM_HEAP_SIZE_KB} * 1024")
set(DEFINES_JERRY_EXTERNAL CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE_EXTERNAL})
endif()

# Include directories
set(INCLUDE_CORE
${CMAKE_SOURCE_DIR}/jerry-core
Expand Down
2 changes: 2 additions & 0 deletions jerry-core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
*/
#ifndef CONFIG_MEM_HEAP_AREA_SIZE
# define CONFIG_MEM_HEAP_AREA_SIZE (256 * 1024)
#elif CONFIG_MEM_HEAP_AREA_SIZE > (256 * 1024)
# error "Currently, maximum 256 kilobytes heap size is supported"
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */

/**
Expand Down

0 comments on commit bc0ca7b

Please sign in to comment.