Skip to content

Commit

Permalink
Added clear methods and memory leak tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kpgalligan committed Feb 15, 2019
1 parent 8c8523a commit 769c987
Show file tree
Hide file tree
Showing 81 changed files with 445 additions and 129 deletions.
6 changes: 6 additions & 0 deletions .idea/artifacts/library_js_0_5_3_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/artifacts/library_jvm_0_5_3_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/artifacts/stately_js_0_6_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/artifacts/stately_jvm_0_6_0_SNAPSHOT.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ Converts an Iterator to a List. This is an extension function that works on any

## Collections

## Important note for all collections!!!

AtomicReference can leak memory in Kotlin Native. To avoid leaking memory, you should call `clear()`
on any collection when done using it.

### Copy On Write List

A MutableList that updates a stable copy on each edit. When you get an iterator, that iterator remains stable regardless
Expand Down
118 changes: 1 addition & 117 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,120 +24,4 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
}
}

apply plugin: 'org.jetbrains.kotlin.multiplatform'

repositories {
mavenCentral()
}

group = GROUP
version = VERSION_NAME

kotlin {
targets {

//Uncomment to refresh intellij plugin
// fromPreset(presets.macosX64, 'nativeCommon')
// fromPreset(presets.macosX64, 'apple')

fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
fromPreset(presets.macosX64, 'macos')
fromPreset(presets.iosX64, 'iosX64')
fromPreset(presets.iosArm32, 'iosArm32')
fromPreset(presets.iosArm64, 'iosArm64')
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
jvmMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
}
jvmTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}

jsMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
}
}
jsTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-js'
}
}

nativeCommonMain {
dependsOn commonMain
}

nativeCommonTest {
dependsOn commonTest
}

appleMain {
dependsOn nativeCommonMain
}

appleTest {
dependsOn nativeCommonTest
}

configure([iosX64Main, iosArm32Main, iosArm64Main, macosMain]) {
dependsOn appleMain
}

configure([iosX64Test, iosArm32Test, iosArm64Test, macosTest]) {
dependsOn appleTest
}

/*otherNativeMain {
dependsOn nativeCommonMain
}
otherNativeTest {
dependsOn nativeCommonTest
}
configure([androidNativeArm32, androidNativeArm64]) {
dependsOn otherNativeMain
}
configure([androidNativeArm32, androidNativeArm64]) {
dependsOn otherNativeTest
}*/
}
}

task iosTest {
def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
dependsOn 'linkTestDebugExecutableIosX64'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Runs tests for target 'ios' on an iOS simulator"

doLast {
def binary = kotlin.targets.iosX64.compilations.test.getBinary('EXECUTABLE', 'DEBUG')
exec {
commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath
}
}
}

apply from: 'gradle/gradle-mvn-mpp-push.gradle'
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kotlin.code.style=official
KOTLIN_VERSION=1.3.21

GROUP=co.touchlab
VERSION_NAME=0.5.3-SNAPSHOT
VERSION_NAME=0.6.0-SNAPSHOT

POM_URL=https://github.com/touchlab/Stately
POM_DESCRIPTION=Multithreaded Kotlin Multiplatform Utilities
Expand Down
6 changes: 6 additions & 0 deletions memtest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# memtest

AtomicReference may leak memory in Kotlin Native. The only way to test if memory is leaked is to
run a debug executable on the command line. This will return non-zero if there is an error, including
memory leaks. Running `build` on this project is sufficient, as it builds and runs the application, and
fails if the app fails.
45 changes: 45 additions & 0 deletions memtest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apply plugin: 'org.jetbrains.kotlin.multiplatform'

repositories {
mavenCentral()
}
kotlin {
// For ARM, should be changed to iosArm32 or iosArm64
// For Linux, should be changed to e.g. linuxX64
// For MacOS, should be changed to e.g. macosX64
// For Windows, should be changed to e.g. mingwX64
macosX64("macos") {
compilations.main {
// Comment to generate Kotlin/Native library (KLIB) instead of executable file:
outputKinds("executable")
// Change to specify fully qualified name of your application's entry point:
entryPoint 'sample.main'
}
}

sourceSets {
// Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
// in gradle.properties file and re-import your project in IDE.
macosMain {
dependencies {
implementation project(":stately")
}
}
macosTest {
}
}
}

task runProgram {
def buildType = 'DEBUG' // Change to 'DEBUG' to run application with debug symbols.
dependsOn kotlin.targets.macos.compilations.main.linkTaskName('EXECUTABLE', buildType)
doLast {
def programFile = kotlin.targets.macos.compilations.main.getBinary('EXECUTABLE', buildType)
exec {
executable programFile
args ''
}
}
}

tasks.build.dependsOn runProgram
Loading

0 comments on commit 769c987

Please sign in to comment.